Skip to content

Commit 7139b51

Browse files
authored
Merge pull request #8741 from anntzer/docs-cleanups
Simplify some examples.
2 parents 545af7a + f1928e6 commit 7139b51

File tree

5 files changed

+26
-70
lines changed

5 files changed

+26
-70
lines changed

doc/faq/howto_faq.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,10 @@ some ratio which controls the ratio::
357357

358358
ax = fig.add_subplot(111, aspect='equal')
359359

360-
361-
362360
.. htmlonly::
363361

364-
See :ref:`sphx_glr_gallery_subplots_axes_and_figures_equal_aspect_ratio.py` for a complete
365-
example.
366-
362+
See :ref:`sphx_glr_gallery_pylab_examples_axis_equal_demo.py` for a
363+
complete example.
367364

368365
.. _howto-twoscale:
369366

examples/pylab_examples/axis_equal_demo.py

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,32 @@
33
Axis Equal Demo
44
===============
55
6-
This example is only interesting when run in interactive mode.
7-
86
"""
97

10-
118
import matplotlib.pyplot as plt
129
import numpy as np
1310

14-
# Plot circle or radius 3
11+
# Plot circle of radius 3.
1512

1613
an = np.linspace(0, 2*np.pi, 100)
14+
fig, axs = plt.subplots(2, 2)
15+
16+
axs[0, 0].plot(3*np.cos(an), 3*np.sin(an))
17+
axs[0, 0].set_title('not equal, looks like ellipse', fontsize=10)
18+
19+
axs[0, 1].plot(3*np.cos(an), 3*np.sin(an))
20+
axs[0, 1].axis('equal')
21+
axs[0, 1].set_title('equal, looks like circle', fontsize=10)
22+
23+
axs[1, 0].plot(3*np.cos(an), 3*np.sin(an))
24+
axs[1, 0].axis('equal')
25+
axs[1, 0].axis([-3, 3, -3, 3])
26+
axs[1, 0].set_title('still a circle, even after changing limits', fontsize=10)
27+
28+
axs[1, 1].plot(3*np.cos(an), 3*np.sin(an))
29+
axs[1, 1].set_aspect('equal', 'box')
30+
axs[1, 1].set_title('still a circle, auto-adjusted data limits', fontsize=10)
1731

18-
plt.subplot(221)
19-
plt.plot(3*np.cos(an), 3*np.sin(an))
20-
plt.title('not equal, looks like ellipse', fontsize=10)
21-
22-
plt.subplot(222)
23-
plt.plot(3*np.cos(an), 3*np.sin(an))
24-
plt.axis('equal')
25-
plt.title('equal, looks like circle', fontsize=10)
26-
27-
plt.subplot(223)
28-
plt.plot(3*np.cos(an), 3*np.sin(an))
29-
plt.axis('equal')
30-
plt.axis([-3, 3, -3, 3])
31-
plt.title('looks like circle, even after changing limits', fontsize=10)
32-
33-
plt.subplot(224)
34-
plt.plot(3*np.cos(an), 3*np.sin(an))
35-
plt.axis('equal')
36-
plt.axis([-3, 3, -3, 3])
37-
plt.plot([0, 4], [0, 4])
38-
plt.title('still equal after adding line', fontsize=10)
39-
40-
plt.tight_layout()
32+
fig.tight_layout()
4133

4234
plt.show()

examples/pylab_examples/vline_hline_demo.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,20 @@
77
"""
88

99
import matplotlib.pyplot as plt
10-
from matplotlib.transforms import blended_transform_factory as btf
1110
import numpy as np
1211

1312

14-
def f(t):
15-
s1 = np.sin(2 * np.pi * t)
16-
e1 = np.exp(-t)
17-
return np.abs(s1 * e1) + .05
18-
1913
t = np.arange(0.0, 5.0, 0.1)
20-
s = f(t)
14+
s = np.exp(-t) + np.sin(2 * np.pi * t) + 1
2115
nse = np.random.normal(0.0, 0.3, t.shape) * s
2216

23-
fig = plt.figure(figsize=(12, 6))
24-
vax = fig.add_subplot(121)
25-
hax = fig.add_subplot(122)
17+
fig, (vax, hax) = plt.subplots(1, 2, figsize=(12, 6))
2618

2719
vax.plot(t, s + nse, '^')
2820
vax.vlines(t, [0], s)
29-
vax.vlines([1, 2], 0, 1, transform=btf(vax.transData, vax.transAxes), colors='r')
21+
# By using ``transform=vax.get_xaxis_transform()`` the y coordinates are scaled
22+
# such that 0 maps to the bottom of the axes and 1 to the top.
23+
vax.vlines([1, 2], 0, 1, transform=vax.get_xaxis_transform(), colors='r')
3024
vax.set_xlabel('time (s)')
3125
vax.set_title('Vertical lines demo')
3226

examples/subplots_axes_and_figures/equal_aspect_ratio.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

examples/tests/backend_driver_sgskip.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@
156156
'ellipse_collection.py',
157157
'ellipse_demo.py',
158158
'ellipse_rotated.py',
159-
'equal_aspect_ratio.py',
160159
'errorbar_limits.py',
161160
'fancyarrow_demo.py',
162161
'fancybox_demo.py',

0 commit comments

Comments
 (0)