密谋:密谋表示什么颜色循环? [英] Plotly: What color cycle does plotly express follow?

查看:99
本文介绍了密谋:密谋表示什么颜色循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为默认颜色周期将是['blue', 'red', 'green', 'purple', 'orange'](的某些变体),如下图所示:

I would think that the default color cycle would be (some variants of) ['blue', 'red', 'green', 'purple', 'orange'] like in the plot below:

情节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会给您以下信息:

At least that seems to be the order of the cycle since omitting Oceania from the continents will give you this:

现在,其余颜色的顺序是相同的,除了最后一个看起来像橙色的颜色(只是表明颜色的应用不是ribribryry).

Now the order of the remaining colors are the same except for the last orange looking one (just showing that the application of the colors are not aribtrary).

我认为可以使用plotly.colors.DEFAULT_PLOTLY_COLORS进行检索,这将为您提供:

I thought this would be possibleto retrieve using plotly.colors.DEFAULT_PLOTLY_COLORS which will give you:

['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']...

But those colors are ordered like ['blue', 'orange', 'green', 'red']...

那么,在px.scatter(gapminder2007, x='gdpPercap', y='lifeExp', color="continent")中设置color="continent"时, 会表现出什么颜色循环?

So, what color cycle does plotly express follow when setting for color="continent" in px.scatter(gapminder2007, x='gdpPercap', y='lifeExp', color="continent")?

我也尝试在help(px.colors)下查看,但这没什么用:

I tried looking under help(px.colors) too, but that didn't give much:

有关plotly.express中的plotly.express.colors模块的帮助:

Help on module plotly.express.colors in plotly.express:

NAME plotly.express.colors

NAME plotly.express.colors

数据 DEFAULT_PLOTLY_COLORS = ['rgb(31,119,180)','rgb(255,127,14)','rg ... PLOTLY_SCALES = {'黑体':[[0,'rgb(0,0,0)'],[0.2,'rgb(230,0,0)'... absolute_import = _Feature((2,5,0,'alpha',1),(3,0,0,'alpha',0 ...

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...

推荐答案

此文档页面涵盖了离散的颜色序列:

This doc page covers discrete color sequences: https://plot.ly/python/discrete-color/ and mentions that the default sequence comes from layout.colorway in the active template.

在名为plotly的默认模板中,这是px.colors.qualitative.Plotly下可用的序列.

In the default template called plotly this is the sequence available under px.colors.qualitative.Plotly.

此顺序为['#636EFA', '#EF553B', '#00CC96', '#AB63FA', '#FFA15A', '#19D3F3', '#FF6692', '#B6E880', '#FF97FF', '#FECB52']

这篇关于密谋:密谋表示什么颜色循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆