How can I set a default set of colors for plots made with matplotlib? I can set a particular color map like this
import numpy as np
import matplotlib.pyplot as plt
fig=plt.figure(i)
ax=plt.gca()
colormap = plt.get_cmap('jet')
ax.set_color_cycle([colormap(k) for k in np.linspace(0, 1, 10)])
but is there some way to set the same set of colors for all plots, including subplots?
Best Answer
Sure! Either specify
axes.color_cycle
in your.matplotlibrc
file or set it at runtime usingmatplotlib.rcParams
ormatplotlib.rc
.As an example of the latter: