constraining axes leads to paper coordinates being off and to extra space between plot area and annotations
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 18.8k
- 派生
- 2.8k
- 平均合并
- 16 小时 26 分钟
- 30 天内合并 PR
- 21
描述
If I constrain the x-axis, a legend to the right of the plot area shows up too far to the right and paper coordinates x=0 and x=1 are no longer at the edges of the plot area. Paper coordinate x=1 should always be the right edge of the plot area. There should not be excessive trapped white space between the legend and the plot area. The constrained, no-width behavior should be similar to the unconstrained and constrained-with-width behaviors.
Here I reproduce the problem using the documentation example here:
https://plotly.com/python/axes/#fixed-ratio-axes
I'm happy to provide and diff the output JSON if that would be helpful
import plotly.graph_objects as go
fig = go.Figure()
fig.add_trace(go.Scatter(
x = [0,1,1,0,0,1,1,2,2,3,3,2,2,3],
y = [0,0,1,1,3,3,2,2,3,3,1,1,0,0],
name="demo"
))
##Add some elements outside the main plot area
fig.update_layout(
title=dict(text="Source: Plotly Bug Report",
yref="container",
xref="paper",
xanchor="right",
x=1, y=0.005),
showlegend=True
)
#the current layout is reasonable -- the legend is close to the plot area and x=1 in paper coordinates is where we expect it.
fig.show()
#now we constrain the domain and it injects lots of space between the plot area and the legend
#paper coordinates no longer reference the plot area -- paper coordinate x=1 is well to the right of the plot area
fig.update_xaxes(
range=[-1,4], # sets the range of xaxis
constrain="domain", # meanwhile compresses the xaxis by decreasing its "domain"
)
fig.update_yaxes(
scaleanchor = "x",
scaleratio = 1
)
fig.show()
#now we specify the width and the layout becomes reasonable again
fig.update_layout(
width = 800,
)
fig.show()
unconstrained graphic (expected behavior):
constrained graphic (unexpected behavior)
constrained graphic with width (expected behavior)
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从链接的文档页面中的固定比例坐标轴示例开始,运行报告中展示的三种布局变体。比较受约束的无宽度结果与无约束结果和显式宽度结果;当 paper x=1 与绘图区的右边缘对齐,且绘图与图例或注释之间不再有过多空白时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100