From 8e2a74583e11fe77f116ee1f1b186f0875d8ce66 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Tue, 30 Jul 2019 16:11:58 -0700 Subject: [PATCH] DOC: Update invert_example to directly manipulate axis. Avoid using the stateful `plt.` way and use the more accepted object oriented way in matplotlib. --- examples/subplots_axes_and_figures/invert_axes.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/subplots_axes_and_figures/invert_axes.py b/examples/subplots_axes_and_figures/invert_axes.py index d8c17a1ba81a..15ec55d430bd 100644 --- a/examples/subplots_axes_and_figures/invert_axes.py +++ b/examples/subplots_axes_and_figures/invert_axes.py @@ -12,13 +12,14 @@ t = np.arange(0.01, 5.0, 0.01) s = np.exp(-t) -plt.plot(t, s) -plt.xlim(5, 0) # decreasing time +fig, ax = plt.subplots() -plt.xlabel('decreasing time (s)') -plt.ylabel('voltage (mV)') -plt.title('Should be growing...') -plt.grid(True) +ax.plot(t, s) +ax.set_xlim(5, 0) # decreasing time +ax.set_xlabel('decreasing time (s)') +ax.set_ylabel('voltage (mV)') +ax.set_title('Should be growing...') +ax.grid(True) plt.show()