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

Skip to content

Commit 753dfa7

Browse files
authored
Merge pull request #8633 from dstansby/pylab-moves
Move some examples out of pylab_examples
2 parents dc6441f + 28be3ce commit 753dfa7

23 files changed

+44
-62
lines changed

doc/users/prev_whats_new/whats_new_1.0.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ indexing (starts with 0). e.g.::
4444
fig, axarr = plt.subplots(2, 2)
4545
axarr[0,0].plot([1,2,3]) # upper, left
4646

47-
See :ref:`sphx_glr_gallery_pylab_examples_subplot_demo.py` for several code examples.
47+
See :ref:`sphx_glr_gallery_subplots_axes_and_figures_subplot_demo.py` for several code examples.
4848

4949
Contour fixes and and triplot
5050
---------------------------------
@@ -147,6 +147,3 @@ Eric Firing went on a bug fixing and closing marathon, closing over
147147
<http://sourceforge.net/tracker/?group_id=80706&atid=560720>`__ with
148148
help from Jae-Joon Lee, Michael Droettboom, Christoph Gohlke and
149149
Michiel de Hoon.
150-
151-
152-

doc/users/prev_whats_new/whats_new_1.5.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ quads touching the point; any triangular corners comprising three unmasked
314314
points are contoured as usual. If the ``corner_mask`` keyword argument is not
315315
specified, the default value is taken from rcParams.
316316

317-
.. figure:: ../../gallery/pylab_examples/images/sphx_glr_contour_corner_mask_001.png
318-
:target: ../../gallery/pylab_examples/contour_corner_mask.html
317+
.. figure:: ../../gallery/images_contours_and_fields/images/sphx_glr_contour_corner_mask_001.png
318+
:target: ../../gallery/images_contours_and_fields/contour_corner_mask.html
319319
:align: center
320320
:scale: 50
321321

@@ -744,6 +744,3 @@ is important if your toolchain is prefixed. This is done in a simpilar
744744
way as setting `CC` or `CXX` before building. An example follows.
745745

746746
export PKG_CONFIG=x86_64-pc-linux-gnu-pkg-config
747-
748-
749-
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
"""
2-
===============
3-
Color By Yvalue
4-
===============
2+
================
3+
Color By y-value
4+
================
55
66
Use masked arrays to plot a line with different colors by y-value.
77
"""
88
import numpy as np
99
import matplotlib.pyplot as plt
1010

1111
t = np.arange(0.0, 2.0, 0.01)
12-
s = np.sin(2*np.pi*t)
12+
s = np.sin(2 * np.pi * t)
1313

1414
upper = 0.77
1515
lower = -0.77
@@ -19,5 +19,6 @@
1919
slower = np.ma.masked_where(s > lower, s)
2020
smiddle = np.ma.masked_where(np.logical_or(s < lower, s > upper), s)
2121

22-
plt.plot(t, smiddle, t, slower, t, supper)
22+
fig, ax = plt.subplots()
23+
ax.plot(t, smiddle, t, slower, t, supper)
2324
plt.show()

examples/pylab_examples/color_demo.py renamed to examples/color/color_demo.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@
2222
import matplotlib.pyplot as plt
2323
import numpy as np
2424

25-
plt.subplot(111, facecolor='darkslategray')
26-
#subplot(111, facecolor='#ababab')
2725
t = np.arange(0.0, 2.0, 0.01)
28-
s = np.sin(2*np.pi*t)
29-
plt.plot(t, s, 'C1')
30-
plt.xlabel('time (s)', color='C1')
31-
plt.ylabel('voltage (mV)', color='0.5') # grayscale color
32-
plt.title('About as silly as it gets, folks', color='#afeeee')
26+
s = np.sin(2 * np.pi * t)
27+
28+
fig, ax = plt.subplots(facecolor='darkslategray')
29+
ax.plot(t, s, 'C1')
30+
ax.set_xlabel('time (s)', color='C1')
31+
ax.set_ylabel('voltage (mV)', color='0.5') # grayscale color
32+
ax.set_title('About as silly as it gets, folks', color='#afeeee')
33+
3334
plt.show()

examples/pylab_examples/contour_corner_mask.py renamed to examples/images_contours_and_fields/contour_corner_mask.py

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

1212
# Data to plot.
1313
x, y = np.meshgrid(np.arange(7), np.arange(10))
14-
z = np.sin(0.5*x)*np.cos(0.52*y)
14+
z = np.sin(0.5 * x) * np.cos(0.52 * y)
1515

1616
# Mask various z values.
1717
mask = np.zeros_like(z, dtype=np.bool)
@@ -24,7 +24,7 @@
2424

2525
corner_masks = [False, True]
2626
for i, corner_mask in enumerate(corner_masks):
27-
plt.subplot(1, 2, i+1)
27+
plt.subplot(1, 2, i + 1)
2828
cs = plt.contourf(x, y, z, corner_mask=corner_mask)
2929
plt.contour(cs, colors='k')
3030
plt.title('corner_mask = {0}'.format(corner_mask))

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@
55
66
"""
77
import matplotlib.pyplot as plt
8-
from numpy import arange, pi, cos, sin
9-
from numpy.random import rand
8+
import numpy as np
109

1110
# unit area ellipse
1211
rx, ry = 3., 1.
13-
area = rx * ry * pi
14-
theta = arange(0, 2*pi + 0.01, 0.1)
15-
verts = list(zip(rx/area*cos(theta), ry/area*sin(theta)))
12+
area = rx * ry * np.pi
13+
theta = np.arange(0, 2 * np.pi + 0.01, 0.1)
14+
verts = list(zip(rx / area * np.cos(theta), ry / area * np.sin(theta)))
1615

17-
x, y, s, c = rand(4, 30)
16+
x, y, s, c = np.random.rand(4, 30)
1817
s *= 10**2.
1918

2019
fig, ax = plt.subplots()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
price_data = np.load(datafile)['price_data'].view(np.recarray)
1717
price_data = price_data[-250:] # get the most recent 250 trading days
1818

19-
delta1 = np.diff(price_data.adj_close)/price_data.adj_close[:-1]
19+
delta1 = np.diff(price_data.adj_close) / price_data.adj_close[:-1]
2020

2121
# Marker size in units of points^2
2222
volume = (15 * price_data.volume[:-2] / price_data.volume[0])**2

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313

1414
N = 100
1515
r0 = 0.6
16-
x = 0.9*np.random.rand(N)
17-
y = 0.9*np.random.rand(N)
18-
area = np.pi*(10 * np.random.rand(N))**2 # 0 to 10 point radii
16+
x = 0.9 * np.random.rand(N)
17+
y = 0.9 * np.random.rand(N)
18+
area = np.pi * (10 * np.random.rand(N))**2 # 0 to 10 point radii
1919
c = np.sqrt(area)
20-
r = np.sqrt(x*x + y*y)
20+
r = np.sqrt(x * x + y * y)
2121
area1 = np.ma.masked_where(r < r0, area)
2222
area2 = np.ma.masked_where(r >= r0, area)
2323
plt.scatter(x, y, s=area1, marker='^', c=c)
2424
plt.scatter(x, y, s=area2, marker='o', c=c)
2525
# Show the boundary between the regions:
26-
theta = np.arange(0, np.pi/2, 0.01)
27-
plt.plot(r0*np.cos(theta), r0*np.sin(theta))
26+
theta = np.arange(0, np.pi / 2, 0.01)
27+
plt.plot(r0 * np.cos(theta), r0 * np.sin(theta))
2828

2929
plt.show()

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929

3030
for N in (20, 100, 1000, 10000, 50000):
3131
tstart = time.time()
32-
x = 0.9*np.random.rand(N)
33-
y = 0.9*np.random.rand(N)
34-
s = 20*np.random.rand(N)
32+
x = 0.9 * np.random.rand(N)
33+
y = 0.9 * np.random.rand(N)
34+
s = 20 * np.random.rand(N)
3535
plt.scatter(x, y, s)
3636
print('%d symbols in %1.2f s' % (N, time.time() - tstart))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
plt.subplot(323)
2626
plt.scatter(x, y, s=80, c=z, marker=(verts, 0))
2727
# equivalent:
28-
#plt.scatter(x,y,s=80, c=z, marker=None, verts=verts)
28+
# plt.scatter(x, y, s=80, c=z, marker=None, verts=verts)
2929

3030
plt.subplot(324)
3131
plt.scatter(x, y, s=80, c=z, marker=(5, 1))

examples/pylab_examples/README

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

examples/pylab_examples/barb_demo.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
x = np.linspace(-5, 5, 5)
1212
X, Y = np.meshgrid(x, x)
13-
U, V = 12*X, 12*Y
13+
U, V = 12 * X, 12 * Y
1414

1515
data = [(-1.5, .5, -6, -6),
1616
(1, -1, -46, 46),
@@ -27,29 +27,29 @@
2727
ax.barbs(X, Y, U, V)
2828

2929
# Arbitrary set of vectors, make them longer and change the pivot point
30-
#(point around which they're rotated) to be the middle
30+
# (point around which they're rotated) to be the middle
3131
ax = plt.subplot(2, 2, 2)
3232
ax.barbs(data['x'], data['y'], data['u'], data['v'], length=8, pivot='middle')
3333

3434
# Showing colormapping with uniform grid. Fill the circle for an empty barb,
3535
# don't round the values, and change some of the size parameters
3636
ax = plt.subplot(2, 2, 3)
37-
ax.barbs(X, Y, U, V, np.sqrt(U*U + V*V), fill_empty=True, rounding=False,
37+
ax.barbs(X, Y, U, V, np.sqrt(U * U + V * V), fill_empty=True, rounding=False,
3838
sizes=dict(emptybarb=0.25, spacing=0.2, height=0.3))
3939

4040
# Change colors as well as the increments for parts of the barbs
4141
ax = plt.subplot(2, 2, 4)
4242
ax.barbs(data['x'], data['y'], data['u'], data['v'], flagcolor='r',
43-
barbcolor=['b', 'g'], barb_increments=dict(half=10, full=20, flag=100),
44-
flip_barb=True)
43+
barbcolor=['b', 'g'],
44+
barb_increments=dict(half=10, full=20, flag=100), flip_barb=True)
4545

4646
# Masked arrays are also supported
4747
masked_u = np.ma.masked_array(data['u'])
4848
masked_u[4] = 1000 # Bad value that should not be plotted when masked
4949
masked_u[4] = np.ma.masked
5050

5151
# Identical plot to panel 2 in the first figure, but with the point at
52-
#(0.5, 0.25) missing (masked)
52+
# (0.5, 0.25) missing (masked)
5353
fig2 = plt.figure()
5454
ax = fig2.add_subplot(1, 1, 1)
5555
ax.barbs(data['x'], data['y'], masked_u, data['v'], length=8, pivot='middle')

tutorials/01_introductory/pyplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def f(t):
278278
# which allows you to specify the location as ``axes([left, bottom,
279279
# width, height])`` where all values are in fractional (0 to 1)
280280
# coordinates. See :ref:`sphx_glr_gallery_pylab_examples_axes_demo.py` for an example of
281-
# placing axes manually and :ref:`sphx_glr_gallery_pylab_examples_subplot_demo.py` for an
281+
# placing axes manually and :ref:`sphx_glr_gallery_subplots_axes_and_figures_subplot_demo.py` for an
282282
# example with lots of subplots.
283283
#
284284
#

tutorials/01_introductory/sample_plots.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@
194194
trading volume and colors varying with time. Here, the
195195
alpha attribute is used to make semitransparent circle markers.
196196
197-
.. figure:: ../../gallery/pylab_examples/images/sphx_glr_scatter_demo2_001.png
198-
:target: ../../gallery/pylab_examples/scatter_demo2.html
197+
.. figure:: ../../gallery/lines_bars_and_markers/images/sphx_glr_scatter_demo2_001.png
198+
:target: ../../gallery/lines_bars_and_markers/scatter_demo2.html
199199
:align: center
200200
:scale: 50
201201

0 commit comments

Comments
 (0)