获取默认线条颜色循环 [英] Get default line colour cycle

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

问题描述

我注意到当你绘制第一条线时是蓝色的,然后是绿色,然后是红色,依此类推.

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

或者等效地,在python2中:

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

在版本<1.5,这被称为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天全站免登陆