diff --git a/examples/lines_bars_and_markers/fill_demo.py b/examples/lines_bars_and_markers/fill_demo.py index 120036516955..3e1879bc7554 100644 --- a/examples/lines_bars_and_markers/fill_demo.py +++ b/examples/lines_bars_and_markers/fill_demo.py @@ -14,18 +14,28 @@ import numpy as np import matplotlib.pyplot as plt -x = np.linspace(0, 1, 500) -y = np.sin(4 * np.pi * x) * np.exp(-5 * x) +x1 = np.linspace(0, 2 * np.pi, 500) -fig, ax = plt.subplots() +y1 = np.sin(x1) +y2 = np.sin(3 * x1) -ax.fill(x, y, zorder=10) -ax.grid(True, zorder=5) +fig, (ax1, ax2) = plt.subplots(1,2, sharey=True) -x = np.linspace(0, 2 * np.pi, 500) -y1 = np.sin(x) -y2 = np.sin(3 * x) +ax1.set_xticks([0, np.pi/2, np.pi, 3*np.pi/2, 2*np.pi]) +ax1.set_xticklabels(['$0$', r'$\frac{\pi}{2}$', r'$\pi$',r'$\frac{3\pi}{2}$',r'$2\pi$']) +ax1.set_title('fill_demo_feature') +ax1.set_xlabel('Time',labelpad=2) +ax1.set_ylabel('Amplitude') +ax1.fill(x1, y1, 'b', x1, y2, 'r', alpha=0.3) +ax1.xaxis.set_label_coords(0.5, -0.1) + +x2 = np.linspace(0, 1, 500) +y3 = np.sin(4 * np.pi * x2) * np.exp(-5 * x2) + +ax2.set_title('fill_demo') +ax2.set_xlabel('Time', labelpad=8) +ax2.fill(x2, y3, zorder=10) +ax2.grid(True, zorder=5) +ax2.xaxis.set_label_coords(0.5, -0.1) -fig, ax = plt.subplots() -ax.fill(x, y1, 'b', x, y2, 'r', alpha=0.3) plt.show()