如何在Plotly Express中更新range_color?
我使用的是Plotly Express,我想显示一些数据:
import plotly.express as px
dfx = px.data.tips()
fig = px.scatter(dfx,
x='total_bill', y='tip',
color='size',
template='plotly_dark',
range_color=[2,4])
我的目标是在定义范围后更新范围颜色。
我尝试了这样的事情:
fig.update_layout(range_color=[3,6])
ValueError: Invalid property specified for object of type plotly.graph_objs.Layout: 'range'
但是没有成功。
您是否知道我需要编写的内容才能更新范围颜色值?
I am using plotly express and I want to display some data:
import plotly.express as px
dfx = px.data.tips()
fig = px.scatter(dfx,
x='total_bill', y='tip',
color='size',
template='plotly_dark',
range_color=[2,4])
My goal is to update the range color after it has been defined.
I tried something like this:
fig.update_layout(range_color=[3,6])
ValueError: Invalid property specified for object of type plotly.graph_objs.Layout: 'range'
but without success.
Are you aware of what I need to write in order to update the range color values?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了更改颜色条的范围,您将更改颜色轴的最大值和最小值。这与图形设置的描述不同,可以在
fig.layout
中找到。To change the range of the color bar, you would change the maximum and minimum values of the color axis. This is different from the description of the graph settings, which can be found in
fig.layout
.我认为您需要在px中使用range_color。扫描函数
这是指向文档的链接 plotly
您也可以
此处查看图。
在 的文档
fig.update_layout(colorscale = dict(...))
update_layout
Layout-ColorScale“ rel =“ nofollow noreferrer”>更新ColorsCale
I think you need to use range_color in the px.scatter function
Here is a link to the documentation plotly
You can also look here at fig.update_coloraxes
update coloraxes
Also just found this in the documentation for
update_layout
fig.update_layout(colorscale=dict(...))
update colorscale