Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

convert some sample plots to use plt.subplots() instead of other methods #17340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 25, 2020
2 changes: 1 addition & 1 deletion 2 examples/pie_and_polar_charts/polar_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions 30 examples/subplots_axes_and_figures/subplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.