在plotly python中定义特定数据的颜色
我实现了一个时间轴来显示我的数据。 要创建我使用的时间轴:
fig = px.timeline(df
, x_start="Start"
, x_end="End"
, y="Name"
, hover_name="Task"
, opacity=0.8
, template='plotly_white'
, height=len(df)*35
, width=1150
, color="Type"
, category_orders=dict(
Name=df["Name"].drop_duplicates().tolist()
)
)
您可以看到颜色基于“类型”。 在我的数据框中,我有两种类型的数据:发布和史诗。 颜色如下所示:
这里的问题是颜色是随机生成的。 但是,我想这样定义颜色:
colors = {'Release':'rgb(255,239,0)', 'Epic':'rgb(148, 76, 228)'}
fig.update(color=colors)
有办法做到这一点吗?
I implemented a Timeline to display my data.
To create the Timeline I used:
fig = px.timeline(df
, x_start="Start"
, x_end="End"
, y="Name"
, hover_name="Task"
, opacity=0.8
, template='plotly_white'
, height=len(df)*35
, width=1150
, color="Type"
, category_orders=dict(
Name=df["Name"].drop_duplicates().tolist()
)
)
You can see that the colors are based on "Type".
In my dataframe I have two types of Data: Releases and Epics.
The colors look like follows:
The problem here is that colors are generated randomly.
However, I would like to define the colors like this:
colors = {'Release':'rgb(255,239,0)', 'Epic':'rgb(148, 76, 228)'}
fig.update(color=colors)
Is there a way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)