更改ploty_express Parallel_category图的基本颜色图
使用Ploty Express
import plotly.express as px
df = px.data.tips()
fig = px.parallel_categories(df)
fig.show()
给出了带有蓝色基颜色的图。
我想在不使用图对象的情况下更改基本颜色。只是从蓝色到灰色的整体颜色。
在我的示例中,通过列分配颜色是不可能的。使用color_continouun_scale
还针对不同的颜色更改。
感谢您的输入。
Creating a parallel_categories with ploty express
import plotly.express as px
df = px.data.tips()
fig = px.parallel_categories(df)
fig.show()
gives a diagram with blue base color.
I would like to change the base color without using graph object. Just the overall color from blue to e.g. gray.
Assigning a color via a column is in my example not possible. Using color_continuous_scale
also aims at a different color change.
Thanks for your input.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Express
我发现可以通过plotly.express来实现这一点。创建一个颜色列表并指定连续的颜色尺度灰色。
注意:
再次,输出图中存在差异。图表还添加了指定颜色的数据,该图将破坏Express的目的。
graph_objects
可以通过使用图形对象指定每个类别来创建相同的图。因此,我们正在创建一个数字列表,以赋予颜色0或1。然后,我们将颜色比例设置为0和1的灰色。此方法的灵感来自官方参考。
express
I have found that this can be achieved with plotly.express. Create a color list and specify a continuous color scale gray.
Note:
Once again, there is a discrepancy in the output graph. The data specified for color is also added to the graph, which defeats the purpose of the express.
graph_objects
The same graph can be created by specifying each category using the graph object. So we are creating a list of numbers to give to the colors, either 0 or 1. Then we set the color scale to gray for both 0 and 1. This approach was inspired by the official reference.
这里的原始答案很有帮助,但错过了
px.paralleal_categories()
fordimensions
中有一个参数,您可以使用它来显示您想要的东西 - 那就是,不显示最终列,称为颜色。以下代码与其他答案相同,除了
dimensions = [...]
包括(还将DF定义为订单)。Original answer here is helpful but missed that there is a parameter in
px.parallel_categories()
fordimensions
, and you can use that to only show what you want - that is, to not show the final column called color.The below code is the same as the other answer except has the
dimensions=[...]
included (and also the df was defined out of order).