获取默认的线条颜色周期 [英] Get default line colour cycle

查看:101
本文介绍了获取默认的线条颜色周期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您绘制第一行时,我注意到第一行是蓝色,然后是绿色,然后是红色,依此类推.

I noticed when you plot that the first line is blue, then green, then red, and so on.

是否有某种方法可以访问此颜色列表?我已经看过一百万篇关于如何更改颜色循环或访问迭代器的文章,但没有关于如何获取默认情况下matplotlib循环通过的颜色列表的文章.

Is there some way to access this list of colours? I've seen a million posts on how to change the colour cycle or access the iterator, but not on how to just get the list of colours that matplotlib cycles through by default.

推荐答案

在matplotlib版本> = 1.5中,可以打印名为axes.prop_cyclercParam:

In matplotlib versions >= 1.5, you can print the rcParam called axes.prop_cycle:

print plt.rcParams['axes.prop_cycle'].by_key()['color']

# [u'#1f77b4', u'#ff7f0e', u'#2ca02c', u'#d62728', u'#9467bd', u'#8c564b', u'#e377c2', u'#7f7f7f', u'#bcbd22', u'#17becf']

或等效地,在python3中:

print(plt.rcParams['axes.prop_cycle'].by_key()['color'])

在版本中< 1.5,这称为color_cycle:

In versions < 1.5, this was called color_cycle:

print plt.rcParams['axes.color_cycle']

# [u'b', u'g', u'r', u'c', u'm', u'y', u'k']

请注意,默认颜色周期在版本2.0.0中已更改 http://matplotlib.org/users/dflt_style_changes.html#colors-in-default-property-cycle

Note that the default color cycle changed in version 2.0.0 http://matplotlib.org/users/dflt_style_changes.html#colors-in-default-property-cycle

这篇关于获取默认的线条颜色周期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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