Skip to content

Simplify some examples. #8741

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 1 commit into from
Jun 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions doc/faq/howto_faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,10 @@ some ratio which controls the ratio::

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



.. htmlonly::

See :ref:`sphx_glr_gallery_subplots_axes_and_figures_equal_aspect_ratio.py` for a complete
example.

See :ref:`sphx_glr_gallery_pylab_examples_axis_equal_demo.py` for a
complete example.

.. _howto-twoscale:

Expand Down
46 changes: 19 additions & 27 deletions examples/pylab_examples/axis_equal_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,32 @@
Axis Equal Demo
===============

This example is only interesting when run in interactive mode.

"""


import matplotlib.pyplot as plt
import numpy as np

# Plot circle or radius 3
# Plot circle of radius 3.

an = np.linspace(0, 2*np.pi, 100)
fig, axs = plt.subplots(2, 2)

axs[0, 0].plot(3*np.cos(an), 3*np.sin(an))
axs[0, 0].set_title('not equal, looks like ellipse', fontsize=10)

axs[0, 1].plot(3*np.cos(an), 3*np.sin(an))
axs[0, 1].axis('equal')
axs[0, 1].set_title('equal, looks like circle', fontsize=10)

axs[1, 0].plot(3*np.cos(an), 3*np.sin(an))
axs[1, 0].axis('equal')
axs[1, 0].axis([-3, 3, -3, 3])
axs[1, 0].set_title('still a circle, even after changing limits', fontsize=10)

axs[1, 1].plot(3*np.cos(an), 3*np.sin(an))
axs[1, 1].set_aspect('equal', 'box')
axs[1, 1].set_title('still a circle, auto-adjusted data limits', fontsize=10)

plt.subplot(221)
plt.plot(3*np.cos(an), 3*np.sin(an))
plt.title('not equal, looks like ellipse', fontsize=10)

plt.subplot(222)
plt.plot(3*np.cos(an), 3*np.sin(an))
plt.axis('equal')
plt.title('equal, looks like circle', fontsize=10)

plt.subplot(223)
plt.plot(3*np.cos(an), 3*np.sin(an))
plt.axis('equal')
plt.axis([-3, 3, -3, 3])
plt.title('looks like circle, even after changing limits', fontsize=10)

plt.subplot(224)
plt.plot(3*np.cos(an), 3*np.sin(an))
plt.axis('equal')
plt.axis([-3, 3, -3, 3])
plt.plot([0, 4], [0, 4])
plt.title('still equal after adding line', fontsize=10)

plt.tight_layout()
fig.tight_layout()

plt.show()
16 changes: 5 additions & 11 deletions examples/pylab_examples/vline_hline_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,20 @@
"""

import matplotlib.pyplot as plt
from matplotlib.transforms import blended_transform_factory as btf
import numpy as np


def f(t):
s1 = np.sin(2 * np.pi * t)
e1 = np.exp(-t)
return np.abs(s1 * e1) + .05

t = np.arange(0.0, 5.0, 0.1)
s = f(t)
s = np.exp(-t) + np.sin(2 * np.pi * t) + 1
nse = np.random.normal(0.0, 0.3, t.shape) * s

fig = plt.figure(figsize=(12, 6))
vax = fig.add_subplot(121)
hax = fig.add_subplot(122)
fig, (vax, hax) = plt.subplots(1, 2, figsize=(12, 6))

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

Expand Down
26 changes: 0 additions & 26 deletions examples/subplots_axes_and_figures/equal_aspect_ratio.py

This file was deleted.

1 change: 0 additions & 1 deletion examples/tests/backend_driver_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@
'ellipse_collection.py',
'ellipse_demo.py',
'ellipse_rotated.py',
'equal_aspect_ratio.py',
'errorbar_limits.py',
'fancyarrow_demo.py',
'fancybox_demo.py',
Expand Down