Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8258 from dstansby/aspect-example
DOC: Clean up equal-aspect example
- Loading branch information
Showing
3 changed files
with
28 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
examples/subplots_axes_and_figures/plot_equal_aspect_ratio.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" | ||
================= | ||
Equal aspect axes | ||
================= | ||
This example shows how to make a plot whose x and y axes have a 1:1 aspect | ||
ratio. | ||
""" | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
t = np.arange(0.0, 1.0 + 0.01, 0.01) | ||
s = np.cos(2 * 2 * np.pi * t) | ||
|
||
fig, ax = plt.subplots() | ||
ax.plot(t, s, '-', lw=2) | ||
|
||
ax.set_xlabel('Time (s)') | ||
ax.set_ylabel('Voltage (mV)') | ||
ax.set_title('About as simple as it gets, folks') | ||
ax.grid(True) | ||
|
||
ax.set_aspect('equal', 'datalim') | ||
|
||
fig.tight_layout() | ||
plt.show() |