我可以在Python绘制中设置此轴样式吗

发布于 2025-01-27 09:07:07 字数 177 浏览 1 评论 0原文

在此处输入图像说明

我正在绘制python-plotly中的ganttchart,我可以设置这个轴风格在Plotly Ganttchart中?

enter image description here

I am plotting a ganttChart in python-plotly,can I set this axis style in plotly ganttChart?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

依 靠 2025-02-03 09:07:07

不幸的是,在此答案时, plotly documently documentation 没有足够的功能创建您要寻找的东西。您能做的最好的方法是更改​​背景颜色和文本颜色,这远非您需要的颜色。

import plotly.express as px
import pandas as pd
import plotly.io as pio
pio.renderers.default = 'browser'


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

fig = px.timeline(df, x_start="Start", x_end="Finish",
                  y="Task",
                  )
fig.update_yaxes(autorange="reversed")
fig.update_xaxes(color="#ffffff")
fig.update_yaxes(color="#ffffff")
fig.update_layout(paper_bgcolor="#48596f")
fig.show()

Unfortunately, at the time of this answer, the plotly documentation does not have enough features to create what you are looking for. The best you can do is change the background color and text color which is extremely far from what you need.

enter image description here

import plotly.express as px
import pandas as pd
import plotly.io as pio
pio.renderers.default = 'browser'


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

fig = px.timeline(df, x_start="Start", x_end="Finish",
                  y="Task",
                  )
fig.update_yaxes(autorange="reversed")
fig.update_xaxes(color="#ffffff")
fig.update_yaxes(color="#ffffff")
fig.update_layout(paper_bgcolor="#48596f")
fig.show()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文