tickvals and ticktext don't work with subcategory axes
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 18.8k
- 派生
- 2.8k
- 平均合并
- 16 小时 26 分钟
- 30 天内合并 PR
- 21
描述
If a plot has multi-category axes there is no way to hide a subcategory labels only and the plot doesn't render at all if tickvals and ticktext are used.
Look at the code without multi-categories:
x_names = ['very.long.name.1', 'very.long.name.2', 'very.long.name.3']
fig = go.Figure(go.Bar(
x=x_names,
y=[10, 20, 30]))
fig.update_layout(
xaxis=dict(
tickvals=x_names,
ticktext=['', '', ''],
))
This works fine and all x-axes labels are hidden. I could achieve the same thing with this:
fig.update_layout(xaxis=dict(showticklabels=False))
However, if this is a multi-category plot it doesn't work at all:
x_names = [['A', 'A', 'B'], ['very.long.name.1', 'very.long.name.2', 'very.long.name.3']]
fig = go.Figure(go.Bar(
x=x_names,
y=[10, 20, 30]))
fig.update_layout(
xaxis=dict(
tickvals=x_names,
ticktext=[['A', 'A', 'B'], ['', '', '']],
))
Setting showticklabels=False hides everything and I didn't find a way to hide just a single category labels.
What is really surprising this doesn't work either even if this doesn't change anything:
x_names = [['A', 'A', 'B'], ['very.long.name.1', 'very.long.name.2', 'very.long.name.3']]
fig = go.Figure(go.Bar(
x=x_names,
y=[10, 20, 30]))
fig.update_layout(
xaxis=dict(
tickvals=x_names,
ticktext=x_names,
))
I believe it should work like this:
tickvalsandticktextwork fine with a multi-category plotsshowticklabelsshould accept a list of booleans, .e.g.[True, False]to be able to hide a given subcategory if this is a multi-category plot
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先复现 issue 中单类别和多类别的示例,并比较由此产生的坐标轴行为。跟踪多类别坐标轴如何处理 xaxis.tickvals、ticktext 和 showticklabels;当 tickvals 和 ticktext 能够用于多类别绘图,并且可以隐藏单个类别标签时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100