import matplotlib.pyplot as plt fig = plt.figure() plt.show() ax = plt.axes() plt.show() ax = plt.axes() line1, = ax.plot([0, 1, 2, 1.5], [3, 1, 2, 4]) plt.show() plt.plot([0, 1, 2, 1.5], [3, 1, 2, 4]) plt.show() top_right_ax = plt.subplot(2, 3, 3) bottom_left_ax = plt.subplot(2, 3, 4) plt.show() import numpy as np x = np.linspace(-180, 180, 60) y = np.linspace(-90, 90, 30) x2d, y2d = np.meshgrid(x, y) data = np.cos(3 * np.deg2rad(x2d)) + np.sin(2 * np.deg2rad(y2d)) plt.contourf(x, y, data) plt.show() plt.imshow(data, extent=[-180, 180, -90, 90], interpolation='nearest', origin='lower') plt.show() plt.pcolormesh(x, y, data) plt.show() plt.scatter(x2d, y2d, c=data, s=15) plt.show() plt.bar(x, data.sum(axis=0), width=np.diff(x)[0]) plt.show() plt.plot(x, data.sum(axis=0), linestyle='--', marker='d', markersize=10, color='red') plt.show() fig = plt.figure() ax = plt.axes() # Adjust the created axes so its topmost extent is 0.8 of the figure. fig.subplots_adjust(top=0.8) fig.suptitle('Figure title', fontsize=18, fontweight='bold') ax.set_title('Axes title', fontsize=16) ax.set_xlabel('The X axis') ax.set_ylabel('The Y axis $y=f(x)$', fontsize=16) ax.text(0.5, 0.5, 'Text centered at (0.5, 0.5)\nin data coordinates.', horizontalalignment='center', fontsize=14) plt.show() x = np.linspace(-3, 7, 200) plt.plot(x, 0.5*x**3 - 3*x**2, linewidth=2, label='$f(x)=0.5x^2-3x^2$') plt.plot(x, 1.5*x**2 - 6*x, linewidth=2, linestyle='--', label='Gradient of $f(x)$', ) plt.legend(loc='lower right') plt.grid() plt.show() x = np.linspace(-180, 180, 60) y = np.linspace(-90, 90, 30) x2d, y2d = np.meshgrid(x, y) data = np.cos(3 * np.deg2rad(x2d)) + np.sin(2 * np.deg2rad(y2d)) plt.contourf(x, y, data) plt.colorbar(orientation='horizontal') plt.show() x = np.linspace(-3, 7, 200) plt.plot(x, 0.5*x**3 - 3*x**2, linewidth=2) plt.annotate('Local minimum', xy=(4, -18), xytext=(-2, -40), fontsize=15, arrowprops={'facecolor': 'black', 'frac': 0.3}) plt.grid() plt.show() plt.plot(range(10)) plt.savefig('simple.svg')