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

Skip to content

Commit 0d1d968

Browse files
authored
Merge pull request #8813 from dstansby/pylab-moves
Move and clean some pylab examples
2 parents e41fca5 + 94bdcbe commit 0d1d968

22 files changed

+121
-121
lines changed

doc/faq/howto_faq.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ specify the location explicitly::
191191
ax = fig.add_axes([left, bottom, width, height])
192192

193193
where all values are in fractional (0 to 1) coordinates. See
194-
:ref:`sphx_glr_gallery_pylab_examples_axes_demo.py` for an example of placing axes manually.
194+
:ref:`sphx_glr_gallery_subplots_axes_and_figures_axes_demo.py` for an example of placing axes manually.
195195

196196
.. _howto-auto-adjust:
197197

@@ -359,7 +359,7 @@ some ratio which controls the ratio::
359359

360360
.. htmlonly::
361361

362-
See :ref:`sphx_glr_gallery_pylab_examples_axis_equal_demo.py` for a
362+
See :ref:`sphx_glr_gallery_subplots_axes_and_figures_axis_equal_demo.py` for a
363363
complete example.
364364

365365
.. _howto-twoscale:
@@ -755,4 +755,3 @@ reference page <http://dx.doi.org/10.1109/MCSE.2007.55>`_)::
755755
development, interactive scripting, and publication-quality image
756756
generation across user interfaces and operating systems.},
757757
Bdsk-Url-1 = {http://gateway.isiknowledge.com/gateway/Gateway.cgi?GWVersion=2&SrcAuth=Alerting&SrcApp=Alerting&DestApp=WOS&DestLinkType=FullRecord;KeyUT=000245668100019}}
758-

examples/pylab_examples/arctest.py renamed to examples/lines_bars_and_markers/arctest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99

1010

1111
def f(t):
12-
'a damped exponential'
12+
'A damped exponential'
1313
s1 = np.cos(2 * np.pi * t)
1414
e1 = np.exp(-t)
1515
return s1 * e1
1616

17-
t1 = np.arange(0.0, 5.0, .2)
1817

18+
t1 = np.arange(0.0, 5.0, .2)
1919

2020
l = plt.plot(t1, f(t1), 'ro')
2121
plt.setp(l, 'markersize', 30)
22-
plt.setp(l, 'markerfacecolor', 'b')
22+
plt.setp(l, 'markerfacecolor', 'C0')
2323

2424
plt.show()

examples/pylab_examples/bar_stacked.py renamed to examples/lines_bars_and_markers/bar_stacked.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
ind = np.arange(N) # the x locations for the groups
2323
width = 0.35 # the width of the bars: can also be len(x) sequence
2424

25-
p1 = plt.bar(ind, menMeans, width, color='#d62728', yerr=menStd)
25+
p1 = plt.bar(ind, menMeans, width, yerr=menStd)
2626
p2 = plt.bar(ind, womenMeans, width,
2727
bottom=menMeans, yerr=womenStd)
2828

examples/pylab_examples/axhspan_demo.py

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

examples/recipes/fill_between_alpha.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,4 @@
133133
# vertical spans of an axes -- for that matplotlib has some helper
134134
# functions :meth:`~matplotlib.axes.Axes.axhspan` and
135135
# :meth:`~matplotlib.axes.Axes.axvspan` and example
136-
# :ref:`sphx_glr_gallery_pylab_examples_axhspan_demo.py`.
136+
# :ref:`sphx_glr_gallery_subplots_axes_and_figures_axhspan_demo.py`.

examples/pylab_examples/anscombe.py renamed to examples/specialty_plots/anscombe.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626

2727
def fit(x):
28-
return 3 + 0.5*x
28+
return 3 + 0.5 * x
2929

3030

3131
xfit = np.array([np.min(x), np.max(x)])
@@ -39,7 +39,8 @@ def fit(x):
3939
plt.subplot(222)
4040
plt.plot(x, y2, 'ks', xfit, fit(xfit), 'r-', lw=2)
4141
plt.axis([2, 20, 2, 14])
42-
plt.setp(plt.gca(), xticklabels=[], yticks=(4, 8, 12), yticklabels=[], xticks=(0, 10, 20))
42+
plt.setp(plt.gca(), xticks=(0, 10, 20), xticklabels=[],
43+
yticks=(4, 8, 12), yticklabels=[], )
4344
plt.text(3, 12, 'II', fontsize=20)
4445

4546
plt.subplot(223)
@@ -58,6 +59,7 @@ def fit(x):
5859
# verify the stats
5960
pairs = (x, y1), (x, y2), (x, y3), (x4, y4)
6061
for x, y in pairs:
61-
print('mean=%1.2f, std=%1.2f, r=%1.2f' % (np.mean(y), np.std(y), np.corrcoef(x, y)[0][1]))
62+
print('mean=%1.2f, std=%1.2f, r=%1.2f' % (np.mean(y), np.std(y),
63+
np.corrcoef(x, y)[0][1]))
6264

6365
plt.show()

examples/pylab_examples/axes_demo.py renamed to examples/subplots_axes_and_figures/axes_demo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
# create some data to use for the plot
1616
dt = 0.001
1717
t = np.arange(0.0, 10.0, dt)
18-
r = np.exp(-t[:1000]/0.05) # impulse response
18+
r = np.exp(-t[:1000] / 0.05) # impulse response
1919
x = np.random.randn(len(t))
20-
s = np.convolve(x, r)[:len(x)]*dt # colored noise
20+
s = np.convolve(x, r)[:len(x)] * dt # colored noise
2121

2222
# the main axes is subplot(111) by default
2323
plt.plot(t, s)
@@ -27,14 +27,14 @@
2727
plt.title('Gaussian colored noise')
2828

2929
# this is an inset axes over the main axes
30-
a = plt.axes([.65, .6, .2, .2], facecolor='y')
30+
a = plt.axes([.65, .6, .2, .2], facecolor='k')
3131
n, bins, patches = plt.hist(s, 400, normed=1)
3232
plt.title('Probability')
3333
plt.xticks([])
3434
plt.yticks([])
3535

3636
# this is another inset axes over the main axes
37-
a = plt.axes([0.2, 0.6, .2, .2], facecolor='y')
37+
a = plt.axes([0.2, 0.6, .2, .2], facecolor='k')
3838
plt.plot(t[:len(r)], r)
3939
plt.title('Impulse response')
4040
plt.xlim(0, 0.2)

examples/pylab_examples/axes_zoom_effect.py renamed to examples/subplots_axes_and_figures/axes_zoom_effect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def connect_bbox(bbox1, bbox2,
1616
prop_lines, prop_patches=None):
1717
if prop_patches is None:
1818
prop_patches = prop_lines.copy()
19-
prop_patches["alpha"] = prop_patches.get("alpha", 1)*0.2
19+
prop_patches["alpha"] = prop_patches.get("alpha", 1) * 0.2
2020

2121
c1 = BboxConnector(bbox1, bbox2, loc1=loc1a, loc2=loc2a, **prop_lines)
2222
c1.set_clip_on(False)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""
2+
============
3+
axhspan Demo
4+
============
5+
6+
Create lines or rectangles that span the axes in either the horizontal or
7+
vertical direction.
8+
"""
9+
import numpy as np
10+
import matplotlib.pyplot as plt
11+
12+
t = np.arange(-1, 2, .01)
13+
s = np.sin(2 * np.pi * t)
14+
15+
plt.plot(t, s)
16+
# Draw a thick red hline at y=0 that spans the xrange
17+
plt.axhline(linewidth=8, color='#d62728')
18+
19+
# Draw a default hline at y=1 that spans the xrange
20+
plt.axhline(y=1)
21+
22+
# Draw a default vline at x=1 that spans the yrange
23+
plt.axvline(x=1)
24+
25+
# Draw a thick blue vline at x=0 that spans the upper quadrant of the yrange
26+
plt.axvline(x=0, ymin=0.75, linewidth=8, color='#1f77b4')
27+
28+
# Draw a default hline at y=.5 that spans the middle half of the axes
29+
plt.axhline(y=.5, xmin=0.25, xmax=0.75)
30+
31+
plt.axhspan(0.25, 0.75, facecolor='0.5', alpha=0.5)
32+
33+
plt.axvspan(1.25, 1.55, facecolor='#2ca02c', alpha=0.5)
34+
35+
plt.axis([-1, 2, -1, 2])
36+
37+
plt.show()

examples/pylab_examples/axis_equal_demo.py renamed to examples/subplots_axes_and_figures/axis_equal_demo.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@
1111

1212
# Plot circle of radius 3.
1313

14-
an = np.linspace(0, 2*np.pi, 100)
14+
an = np.linspace(0, 2 * np.pi, 100)
1515
fig, axs = plt.subplots(2, 2)
1616

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

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

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

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

0 commit comments

Comments
 (0)