我认为默认的颜色循环应该是(一些变体)['blue', 'red', 'green', 'purple', 'orange']
,如下图所示:
绘图1:
代码1:
import plotly
import plotly.express as px
gapminder = px.data.gapminder()
gapminder2007=gapminder.query("year==2007")
px.scatter(gapminder2007, x='gdpPercap', y='lifeExp', color="continent")
至少,似乎是周期的顺序,因为从大陆上省略Oceania
将得到以下结果:
现在,除了最后一个看起来是橙色的颜色外,其余颜色的顺序是相同的(只是表明颜色的应用并不罕见)
我认为可以使用plotly.colors.DEFAULT_PLOTLY_COLORS
进行检索,它将为您提供:
['rgb(31, 119, 180)',
'rgb(255, 127, 14)',
'rgb(44, 160, 44)',
'rgb(214, 39, 40)',
'rgb(148, 103, 189)',
'rgb(140, 86, 75)',
'rgb(227, 119, 194)',
'rgb(127, 127, 127)',
'rgb(188, 189, 34)',
'rgb(23, 190, 207)']
但是这些颜色的顺序是['blue', 'orange', 'green', 'red']...
那么,在px.scatter(gapminder2007, x='gdpPercap', y='lifeExp', color="continent")
中设置color="continent"
时,会遵循什么颜色循环
我也试着在help(px.colors)
下搜索,但没有给出多少结果:
Help on module plotly.express.colors in plotly.express:
NAME plotly.express.colors
DATA DEFAULT_PLOTLY_COLORS = ['rgb(31, 119, 180)', 'rgb(255, 127, 14)', 'rg... PLOTLY_SCALES = {'Blackbody': [[0, 'rgb(0,0,0)'], [0.2, 'rgb(230,0,0)'... absolute_import = _Feature((2, 5, 0, 'alpha', 1), (3, 0, 0, 'alpha', 0...
此文档页面涵盖离散颜色序列:https://plot.ly/python/discrete-color/,并提到默认序列来自活动模板中的
layout.colorway
在名为
plotly
的默认模板中,这是px.colors.qualitative.Plotly
下可用的序列这个序列是
['#636EFA', '#EF553B', '#00CC96', '#AB63FA', '#FFA15A', '#19D3F3', '#FF6692', '#B6E880', '#FF97FF', '#FECB52']
相关问题 更多 >
编程相关推荐