annotation coordinates do not respect log scaling
未关闭
还没有人认领这个 Issue。
bug
P3
- 主要语言
- Python
- 星标
- 18.8k
- 派生
- 2.8k
- 平均合并
- 16 小时 26 分钟
- 30 天内合并 PR
- 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 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
未指定源文件或测试。首先复现一个 x 轴和 y 轴采用对数刻度的最小示例,然后跟踪注释和轴坐标的处理方式;完成的标准是注释能够在对数轴上接受实际数据坐标,同时日期和其他轴类型仍能正常工作,而不改变底层数据。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- plotly, python
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100