1""" 2===================== 3Grayscale style sheet 4===================== 5 6This example demonstrates the "grayscale" style sheet, which changes all colors 7that are defined as rc parameters to grayscale. Note, however, that not all 8plot elements default to colors defined by an rc parameter. 9 10""" 11import numpy as np 12import matplotlib.pyplot as plt 13 14# Fixing random state for reproducibility 15np.random.seed(19680801) 16 17 18def color_cycle_example(ax): 19 L = 6 20 x = np.linspace(0, L) 21 ncolors = len(plt.rcParams['axes.prop_cycle']) 22 shift = np.linspace(0, L, ncolors, endpoint=False) 23 for s in shift: 24 ax.plot(x, np.sin(x + s), 'o-') 25 26 27def image_and_patch_example(ax): 28 ax.imshow(np.random.random(size=(20, 20)), interpolation='none') 29 c = plt.Circle((5, 5), radius=5, label='patch') 30 ax.add_patch(c) 31 32 33plt.style.use('grayscale') 34 35fig, (ax1, ax2) = plt.subplots(ncols=2) 36fig.suptitle("'grayscale' style sheet") 37 38color_cycle_example(ax1) 39image_and_patch_example(ax2) 40 41plt.show() 42