Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Reassigning Yaxis Labels Inconsistent When Using hoversubplots & hovermode set

未关闭
#4,777 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python

调研方向

运行提供的 Python 复现代码,并检查在 hoversubplots="axis" 和 hovermode="x unified" 下六个 y 轴生成的图形布局及悬停行为。追踪为什么两个已分配的 y 轴标题未显示,并在六个标签都可以一致地重命名且该行为有回归测试覆盖时,认为 issue 已完成。

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

描述

I've been having an issue when you define two xaxes and populate three yaxes per xaxis (in a 2x3) grid while setting "hoversubplots= "axis"", with "hovermode= "xunified"". I've found I cannot rename two of the 6 Yaxis labels.

import plotly.graph_objects as go
from datetime import date
from plotly import subplots
import random

def get_test_data():
    x_data, y_data = [], []
    for v in range(30):
        x_data.append(date(2024, 10, v+1))
        y_data.append(random.random())
    return x_data, y_data

data= []
for yaxis in range(1,7):

    if yaxis % 2:
        xaxis = "x1"
    else:
        xaxis= "x2"

    x, y = get_test_data()
    data.append(go.Scatter(x= x, y= y, xaxis= f"{xaxis}", yaxis= f"y{yaxis}", name= f"Test{yaxis}y{yaxis}"))

titles = ["First","Second","Third","Fourth","Fifth","Sixth"]
layout = dict(
    hoversubplots= "axis",
    hovermode= "x unified",
    title= "Test Plot",
    font= dict(
        family= "Courier New, monospace",
        size= 14,
        color= "rgba(255,255,255,1)"),
    plot_bgcolor= "rgba(0,0,0,1)",
    paper_bgcolor= "rgba(0,0,0,1)",
    grid= dict(rows=3, columns=2),
    )

figure= subplots.make_subplots(rows= 3, cols=2, subplot_titles= titles, specs= [[{},{}] for i in range(3)])
figure.add_traces(data[0])
figure.add_traces(data[1])
figure.add_traces(data[2])
figure.add_traces(data[3])
figure.add_traces(data[4])
figure.add_traces(data[5])
figure["layout"][f"yaxis1"]["title"] = "yaxis1"
figure["layout"][f"yaxis2"]["title"] = "yaxis2"
figure["layout"][f"yaxis3"]["title"] = "yaxis3"
figure["layout"][f"yaxis4"]["title"] = "yaxis4"
figure["layout"][f"yaxis5"]["title"] = "yaxis5"
figure["layout"][f"yaxis6"]["title"] = "yaxis6"

figure.update_layout(layout)
figure.update_xaxes(gridcolor="rgba(80,80,80,1)", showticklabels= True)
figure.update_yaxes(gridcolor="rgba(80,80,80,1)", autorange= True, showticklabels= True)

figure.show()
主要语言
Python
星标
18.8k
派生
2.8k
平均合并
13 小时 41 分钟
30 天内合并 PR
21

贡献指南

打开贡献指南

从这里开始

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

plotly/plotly.py 的其他 Issue

查看 plotly/plotly.py 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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