Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 16b4ce4

Browse files
authored
Merge pull request #8258 from dstansby/aspect-example
DOC: Clean up equal-aspect example
2 parents 6060a40 + f6e2784 commit 16b4ce4

File tree

3 files changed

+28
-21
lines changed

3 files changed

+28
-21
lines changed

doc/faq/howto_faq.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ some ratio which controls the ratio::
353353

354354
.. htmlonly::
355355

356-
See :ref:`pylab_examples-equal_aspect_ratio` for a complete example.
356+
See :ref:`subplots_axes_and_figures-plot_equal_aspect_ratio` for a complete
357+
example.
357358

358359

359360
.. _howto-twoscale:

examples/pylab_examples/equal_aspect_ratio.py

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""
2+
=================
3+
Equal aspect axes
4+
=================
5+
6+
This example shows how to make a plot whose x and y axes have a 1:1 aspect
7+
ratio.
8+
"""
9+
import matplotlib.pyplot as plt
10+
import numpy as np
11+
12+
t = np.arange(0.0, 1.0 + 0.01, 0.01)
13+
s = np.cos(2 * 2 * np.pi * t)
14+
15+
fig, ax = plt.subplots()
16+
ax.plot(t, s, '-', lw=2)
17+
18+
ax.set_xlabel('Time (s)')
19+
ax.set_ylabel('Voltage (mV)')
20+
ax.set_title('About as simple as it gets, folks')
21+
ax.grid(True)
22+
23+
ax.set_aspect('equal', 'datalim')
24+
25+
fig.tight_layout()
26+
plt.show()

0 commit comments

Comments
 (0)