I noticed when you plot that the first line is blue, then orange, then green, and so on.
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.
Advertisement
Answer
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']
Or equivalently, in python2
:
print plt.rcParams['axes.prop_cycle'].by_key()['color']
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']
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