情节表达如何取消选择和隐藏Y轴上的时间表(作业)?

发布于 2025-01-31 13:02:20 字数 893 浏览 3 评论 0原文

我需要选项来取消选择Y轴上的多个时间轴(作业),以使它们被隐藏。例如,以下示例代码。


import plotly.express as px
import pandas as pd

df = pd.DataFrame([
    dict(Task="Job A", Start='2009-01-01', Finish='2009-02-28'),
    dict(Task="Job B", Start='2009-03-05', Finish='2009-04-15'),
    dict(Task="Job C", Start='2009-02-20', Finish='2009-05-30')
])

fig = px.timeline(df, x_start="Start", x_end="Finish", y="Task")
fig.update_yaxes(autorange="reversed") # otherwise tasks are listed from the bottom up
fig.show()

给出这个图

我需要选择取消选择一个或多个Y轴作业A/B/C,以便隐藏它们?

我发现以下类似问题。但是它将Y轴分为类别,而不是可选的选项。 y-axis不符合时间表的数量

I need the option to deselect multiple timeline (jobs) on y-axis so that they are hidden. For example following sample code.


import plotly.express as px
import pandas as pd

df = pd.DataFrame([
    dict(Task="Job A", Start='2009-01-01', Finish='2009-02-28'),
    dict(Task="Job B", Start='2009-03-05', Finish='2009-04-15'),
    dict(Task="Job C", Start='2009-02-20', Finish='2009-05-30')
])

fig = px.timeline(df, x_start="Start", x_end="Finish", y="Task")
fig.update_yaxes(autorange="reversed") # otherwise tasks are listed from the bottom up
fig.show()

Gives this plot
enter image description here

I need to option to deselect one or more y-axis Job A/B/C so that they are hidden?

I Found following similar question. But it divides y-axis into categories, instead of selectable options.
Y-axis doesn't fit the number of timelines

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文