annotation coordinates do not respect log scaling
オープン
まだ誰も着手していません。
bug
P3
- 主要言語
- Python
- スター
- 18.8k
- フォーク
- 2.8k
- 平均マージ
- 16時間 26分
- マージ済み PR(30日)
- 21
説明
When adding annotations to a plot that uses log scaling, the annotation coordinates need to be rescaled to represent the log10 of the actual coordinates. While this is documented behavior, it is rather counterintuitive and should be fixed.
Seemingly no other axis-types (date, for instance) needs special treatment but works without modifying the underlying data.
Minimum example demonstrating the point, i.e. label_y is 4 but plotted at 10^4:
df = pd.DataFrame(data={'x':[1,2,3,4],
'y':[1,4,9,16],
})
fig = px.line(df,
x='x',
y='y',
log_y=True,
log_x=True,
)
annotations = []
fig.for_each_trace(
lambda trace: annotations.append(dict(x=np.log10(np.sqrt(trace.x[0]*trace.x[-1])),
y=np.sqrt(trace.y[0]*trace.y[-1]),
text=f'({np.sqrt(trace.x[0]*trace.x[-1])},{np.sqrt(trace.y[0]*trace.y[-1])})',))
)
fig.update_layout(annotations=annotations,
width=300,
height=300,
)
fig.show()

コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
ソースファイルもテストも指定されていません。まず、x 軸と y 軸を対数スケールにした最小限の例を再現し、次にアノテーションと軸座標がどのように扱われているかを追跡してください。対数軸上でアノテーションが実際のデータ座標を受け付け、日付やその他の軸タイプも基になるデータを変更せずに引き続き動作すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- plotly, python
- 領域
- data-visualization
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100