Skip to content

Commit

Permalink
docs(matplotlib): update examples to close the plots
Browse files Browse the repository at this point in the history
  • Loading branch information
bigfooted authored and jourdain committed Oct 5, 2023
1 parent e447803 commit 1f11e35
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions examples/05_charts/Matplotlib/00_matplotlib-charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def figure_size():


def FirstDemo():
plt.close("all")
fig, ax = plt.subplots(**figure_size())
np.random.seed(0)
ax.plot(
Expand All @@ -63,6 +64,7 @@ def FirstDemo():


def MultiLines():
plt.close("all")
fig, ax = plt.subplots(**figure_size())
x = np.linspace(0, 10, 1000)
for offset in np.linspace(0, 3, 7):
Expand All @@ -78,6 +80,7 @@ def MultiLines():


def DotsandPoints():
plt.close("all")
fig, ax = plt.subplots(**figure_size())
ax.plot(
np.random.rand(20),
Expand Down Expand Up @@ -108,11 +111,11 @@ def MovingWindowAverage():

kernel = np.ones(25) / 25.0
x_smooth = np.convolve(x + dx, kernel, mode="same")

plt.close("all")
fig, ax = plt.subplots(**figure_size())
ax.plot(t, x + dx, linestyle="", marker="o", color="black", markersize=3, alpha=0.3)
ax.plot(t, x_smooth, "-k", lw=3)
ax.plot(t, x, "--k", lw=3, color="blue")
ax.plot(t, x, "--", lw=3, color="blue")

return fig

Expand All @@ -121,6 +124,7 @@ def MovingWindowAverage():


def Subplots():
plt.close("all")
fig = plt.figure(**figure_size())
fig.subplots_adjust(hspace=0.3)

Expand Down

0 comments on commit 1f11e35

Please sign in to comment.