Python-Matplotlib 24 样式和美化
EG1:
import numpy as np import matplotlib.pyplot as plt print(plt.style.available) plt.style.use('bmh') # bmh ncolors = len(plt.rcParams['axes.color_cycle']) fix, axes = plt.subplots(ncols=2, nrows=2) ax1, ax2, ax3, ax4 = axes.ravel() x, y = np.random.normal(size=(2, 100)) ax1.plot(x, y, 'o') x = np.arange(0, 10) y = x ax2.plot(x, y, ) ax2.plot(x, y + 1, ) ax2.plot(x, y + 2, ) ax2.plot(x, y + 3, ) ax2.plot(x, y + 4, ) ax2.plot(x, y + 5, ) ax2.plot(x, y + 6, ) x = np.arange(5) y1, y2, y3 = np.random.randint(1, 25, size=(3, 5)) print(y1, y2, y3) width = 0.2 ax3.bar(x + width, y1, width, color=plt.rcParams['axes.color_cycle'][0]) ax3.bar(x + width * 2, y2, width, color=plt.rcParams['axes.color_cycle'][1]) ax3.bar(x + width * 3, y3, width, color=plt.rcParams['axes.color_cycle'][2]) for i,color in enumerate(plt.rcParams['axes.color_cycle']): xy = np.random.normal(size=2) ax4.add_patch(plt.Circle(xy, radius=0.1 , color=color)) plt.show()