问题描述
axes.color_cycle
。但是,它的用法非常简单:我们可以通过以下方式轻松获取特定颜色:
axes.color_cycle
is deprecated in Matplotlib 1.5. However its usage was quite straightforward: we could easily grab a specific color by:
plt.rcParams['axes.color_cycle'][color_number]
axes.prop_cycle
支持以下语法:
ValueError: Can only use slices with Cycler.__getitem__
Cycler的文档不是很详细
And cycler doc is not very detailed http://matplotlib.org/cycler/
所以我不知道如何从prop_cycle中获得特定颜色。任何的想法?
谢谢
So I don't know how I can get a specific color from prop_cycle. Any idea?Thanks
推荐答案
获得所需的值:
list(mpl.rcParams['axes.prop_cycle'])[1]['color'])
有一个打开的要添加 by_key
方法用于 Cycler
对象,因此最终将是
There is an open PR to add a by_key
method to Cycler
objects so this will eventually be
mpl.rcParams['axes.prop_cycle'].by_key()['color'][1]
关于将颜色'c1'
映射到 prop_cycle中的第一个颜色也有一些讨论。
,但尚未实现。
There are also some discussions about mapping the color 'c1'
to the first color in the prop_cycle
, but that has not been implemented yet.
我是Cycler文档的主要作者,您还想在那里看到哪些其他详细信息? ?
I am the main author of the cycler docs, what additional detail would you want to see there?
这篇关于Matplotlib 1.5 axes.prop_cycle的用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!