diff --git a/examples/pie_and_polar_charts/polar_demo.py b/examples/pie_and_polar_charts/polar_demo.py index 1ba897a9fa48..83d12771f09e 100644 --- a/examples/pie_and_polar_charts/polar_demo.py +++ b/examples/pie_and_polar_charts/polar_demo.py @@ -12,7 +12,7 @@ r = np.arange(0, 2, 0.01) theta = 2 * np.pi * r -ax = plt.subplot(111, projection='polar') +fig, ax = plt.subplots(subplot_kw={'projection': 'polar'}) ax.plot(theta, r) ax.set_rmax(2) ax.set_rticks([0.5, 1, 1.5, 2]) # Less radial ticks diff --git a/examples/subplots_axes_and_figures/subplot.py b/examples/subplots_axes_and_figures/subplot.py index 8457fba09926..5502d7c23f2b 100644 --- a/examples/subplots_axes_and_figures/subplot.py +++ b/examples/subplots_axes_and_figures/subplot.py @@ -8,6 +8,36 @@ import numpy as np import matplotlib.pyplot as plt +############################################################################### + +x1 = np.linspace(0.0, 5.0) +x2 = np.linspace(0.0, 2.0) + +y1 = np.cos(2 * np.pi * x1) * np.exp(-x1) +y2 = np.cos(2 * np.pi * x2) + +fig, (ax1, ax2) = plt.subplots(2, 1) +fig.suptitle('A tale of 2 subplots') + +ax1.plot(x1, y1, 'o-') +ax1.set_ylabel('Damped oscillation') + +ax2.plot(x2, y2, '.-') +ax2.set_xlabel('time (s)') +ax2.set_ylabel('Undamped') + +plt.show() + +############################################################################# +# +# +# Alternative Method For Creating Multiple Plots +# """""""""""""""""""""""""""""""""""""""""""""" +# +# Subplots can also be generated using `~.pyplot.subplot()` \ +# as in the following example: +# + x1 = np.linspace(0.0, 5.0) x2 = np.linspace(0.0, 2.0)