Note

Go to the endto download the full example code.

Grayscale style sheet#

This example demonstrates the "grayscale" style sheet, which changes all colorsthat are defined asrcParams to grayscale. Note, however, that not allplot elements respectrcParams.

'grayscale' style sheet
importmatplotlib.pyplotaspltimportnumpyasnp# Fixing random state for reproducibilitynp.random.seed(19680801)defcolor_cycle_example(ax):L=6x=np.linspace(0,L)ncolors=len(plt.rcParams['axes.prop_cycle'])shift=np.linspace(0,L,ncolors,endpoint=False)forsinshift:ax.plot(x,np.sin(x+s),'o-')defimage_and_patch_example(ax):ax.imshow(np.random.random(size=(20,20)),interpolation='none')c=plt.Circle((5,5),radius=5,label='patch')ax.add_patch(c)plt.style.use('grayscale')fig,(ax1,ax2)=plt.subplots(ncols=2)fig.suptitle("'grayscale' style sheet")color_cycle_example(ax1)image_and_patch_example(ax2)plt.show()

Gallery generated by Sphinx-Gallery