Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions examples/lines_bars_and_markers/fill_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's make this x = np.linspace(0, 1, 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()