8000 Cleanup and move subplot_demo · matplotlib/matplotlib@e244d9b · GitHub
[go: up one dir, main page]

Skip to content

Commit e244d9b

Browse files
committed
Cleanup and move subplot_demo
1 parent c0f42d7 commit e244d9b

File tree

5 files changed

+49
-23
lines changed

5 files changed

+49
-23
lines changed

doc/users/screenshots.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Subplot demo
2222
Multiple regular axes (numrows by numcolumns) are created with the
2323
:func:`~matplotlib.pyplot.subplot` command.
2424

25-
.. plot:: mpl_examples/pylab_examples/subplot_demo.py
25+
.. plot:: mpl_examples/subplots_axes_and_figures/subplot_demo.py
2626

2727
.. _screenshots_histogram_demo:
2828

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1-
#!/usr/bin/env python
2-
from pylab import *
1+
"""
2+
Simple demo with multiple subplots.
3+
"""
4+
import numpy as np
5+
import matplotlib.pyplot as plt
36

4-
def f(t):
5-
s1 = cos(2*pi*t)
6-
e1 = exp(-t)
7-
return multiply(s1,e1)
87

9-
t1 = arange(0.0, 5.0, 0.1)
10-
t2 = arange(0.0, 5.0, 0.02)
11-
t3 = arange(0.0, 2.0, 0.01)
8+
x1 = np.linspace(0.0, 5.0)
9+
x2 = np.linspace(0.0, 2.0)
1210

13-
subplot(211)
14-
l = plot(t1, f(t1), 'bo', t2, f(t2), 'k--', markerfacecolor='green')
15-
grid(True)
16-
title('A tale of 2 subplots')
17-
ylabel('Damped oscillation')
11+
y1 = np.cos(2 * np.pi * x1) * np.exp(-x1)
12+
y2 = np.cos(2 * np.pi * x2)
1813

19-
subplot(212)
20-
plot(t3, cos(2*pi*t3), 'r.')
21-
grid(True)
22-
xlabel('time (s)')
23-
ylabel('Undamped')
24-
show()
14+
plt.subplot(2, 1, 1)
15+
plt.plot(x1, y1, 'ko-')
16+
plt.title('A tale of 2 subplots')
17+
plt.ylabel('Damped oscillation')
2518

19+
plt.subplot(2, 1, 2)
20+
plt.plot(x2, y2, 'r.-')
21+
plt.xlabel('time (s)')
22+
plt.ylabel('Undamped')
23+
24+
plt.show()
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
Simple demo with multiple subplots.
3+
"""
4+
import numpy as np
5+
import matplotlib.pyplot as plt
6+
7+
8+
x1 = np.linspace(0.0, 5.0)
9+
x2 = np.linspace(0.0, 2.0)
10+
11+
y1 = np.cos(2 * np.pi * x1) * np.exp(-x1)
12+
y2 = np.cos(2 * np.pi * x2)
13+
14+
plt.subplot(2, 1, 1)
15+
plt.plot(x1, y1, 'yo-')
16+
plt.title('A tale of 2 subplots')
17+
plt.ylabel('Damped oscillation')
18+
19+
plt.subplot(2, 1, 2)
20+
plt.plot(x2, y2, 'r.-')
21+
plt.xlabel('time (s)')
22+
plt.ylabel('Undamped')
23+
24+
plt.show()

examples/tests/backend_driver.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@
7676
'pie_demo.py',
7777
]
7878

79+
files['subplots_axes_and_figures'] = [
80+
'subplot_demo.py',
81+
]
82+
7983
files['pylab'] = [
8084
'accented_text.py',
8185
'alignment_test.py',
@@ -222,7 +226,6 @@
222226
'step_demo.py',
223227
'stix_fonts_demo.py',
224228
'stock_demo.py',
225-
'subplot_demo.py',
226229
'subplots_adjust.py',
227230
'symlog_demo.py',
228231
'table_demo.py',

lib/matplotlib/pyplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ def subplot(*args, **kwargs):
768768
769769
**Example:**
770770
771-
.. plot:: mpl_examples/pylab_examples/subplot_demo.py
771+
.. plot:: mpl_examples/subplots_axes_and_figures/subplot_demo.py
772772
773773
"""
774774
# if subplot called without arguments, create subplot(1,1,1)

0 commit comments

Comments
 (0)
0