Plotly
Plotly: Low-Code Data App Development
plotly/plotly.py: The interactive graphing library for Python This project now includes Plotly Express!
Plotly.pyによるデータ可視化のすすめ | フューチャー技術ブログ
令和時代のPython作図ライブラリのデファクトスタンダードPlotlyExpressの基本的な描き方まとめ Python - Qiita
go は import plotly.graph_objects as go のこと
ボトムアップに fig = go.Figure(), fig.add_trace(go.Scatter(...)) と組み立てなくても
fig = px.scatter(...), for trace in fig.data で図を書いた後に trace にアクセスできる
色分け
color="foo_id" foo_id 列の値で色分けする
color_discrete_map={"(?)": "lightgray"}, 階層などで foo_id がない時に使われる色指定、gainsboro
いいグラフ
Plotly Python Graphing Library
Icicle charts in Python ツリー的なものを表示したい時にいい気がする & DataFrame と path 渡して作れる
Sunburst charts in Python はちょっと主張強い、円形である必要あるなら...
treemap もありだがラベルテキスト短くないときつい
update_traces
texttemplate
Customize Displayed Text with a Text Template - Text and annotations in Python
d3-3.x-api-reference/Formatting.md at master · d3/d3-3.x-api-reference
code:texttemplate.py
fig = px.foo(...)
fig.update_traces(texttemplate='%{label}')
のように指定するやつは d3 の template 形式、textinfo を上書きする
'%{label} <br> %{value:$.2f}'
css 書いて text の word-wrap 設定したいと思ったけど svg 内なのでむりそう
3次元散布図
hover_data に指定したらホバーで読める
lables でも読めそうだけどなんか出なかった、条件があるのかも
code:scatter.py
import plotly.express as px
fig = px.scatter_3d(
df_tsne, x='x', y='y', z='z', color='meaning', hover_data='text', 'lang'
)
fig.show()
カラーパレット連続値か離散値か
Scatter plots in Python
数値なら連続値扱い、ラベルとして扱いたいなら文字列型の列を color にわたす
iframe でサイトに埋め込む
Plotlyをオフラインで使う方法 | Plotly徹底解説 - 韜晦日記