2022年1月13日木曜日

plotly in Jupyter

Jupyter Lab にて plotly の図が表示されませんでした。

公式HPを見てみると、以下の案内がありました。
https://plotly.com/python/getting-started/

$ conda install "ipywidgets>=7.6"
$ conda install -c plotly jupyter-dash
$ conda install python-kaleido

はい、これで無事に表示されました。

以前は Surfer で作成していた地形変化の図化(色塗りコンター)。今は Plotly でも対応可。xyz の DataFrame にしてしまえば、容易に図化できます。個人的には メッシュ配列に加工しなくて良いため、matplotlib よりも好みです。

  1. import plotly.graph_objects as go
  2. import plotly.offline as offline
  3.  
  4. fig = go.Figure(data =go.Contour(z=df.z,x=df.x,y=df.y,))
  5. fig.update_layout(title='contou',
  6.                   autosize=False, width=500, height=500,
  7.                   xaxis=dict(ticks='outside'),
  8.                   yaxis=dict(ticks='outside'),
  9.                   margin=dict(l=20, r=20, b=20, t=20))
  10. fig.update_traces(zmin=-100,zmax=100,colorscale= 'Edge')
  11. #fig.show()
  12. offline.iplot(fig, filename='contour', image='png')
  13. fig.write_image('./contour.png')
  14.  

0 件のコメント:

コメントを投稿