plotly / plotly/plotly.py

axis label change via updatemenus not working anymore in 6.0.0

未关闭
#5,032 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

bug P1
主要语言
Python
星标
18.8k
派生
2.8k
平均合并
16 小时 26 分钟
30 天内合并 PR
21

描述

When using fig.update_layout(updatemenus=updatemenus) to change the label of an axis, the axis label just disappears.
Here you find a minimum example that works in 5.24.1 but not anymore in 6.0.0.

import plotly.graph_objects as go
import pandas as pd

data = pd.DataFrame({'x0': (1, 2, 3),
                     'x1': (1, 2, 5),
                     'y0': (5, 6, 8),
                     'y1': (6, 5, 9)})

fig = go.Figure()

fig.add_trace(go.Scatter(x=data['x0'],
                         y=data['y0'],
                         name='0'))

fig.update_xaxes(title='x0')
fig.update_yaxes(title='y0')

bt = []

bt.append(dict(method='update',
               label='0',
               args=list((
                          dict(x=[data['x0']],
                               y=[data['y0']]),
                          dict(xaxis=dict(title='x0'),
                               yaxis=dict(title='y0'))
                         ))))

bt.append(dict(method='update',
               label='1',
               args=list((
                          dict(x=[data['x1']],
                               y=[data['y1']]),
                          dict(xaxis=dict(title='x1'),
                               yaxis=dict(title='y1'))
                         ))))

updatemenus = [{'buttons': bt,
                'showactive': True}]

fig.update_layout(updatemenus=updatemenus)
fig.show(config={'displayModeBar': False})
# fig.write_html('test_5.24.1.html', config={'displayModeBar': False})
fig.write_html('test_6.0.0.html', config={'displayModeBar': False})

To quickly test on the output html files (try the dropdown menu and look at the labels):

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 issue 中的最小 Python 示例开始,在使用 updatemenu 的同时比较生成的 test_5.24.1.html 和 test_6.0.0.html 输出。跟踪相关 Plotly 代码中的轴标题更新行为,然后验证选择每个按钮后,生成的 HTML 中仍保留预期的 x 和 y 标签。

由索引模型根据 Issue 内容生成。

评估

技术栈
pandas, python
领域
data-visualization
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
活跃
描述清晰度
描述清楚
新手友好度
66/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。