Skip to content

Commit 2ff0db1

Browse files
authored
Merge pull request #8857 from dstansby/pylab-moves2
Pylab example moves 2
2 parents 1a835d9 + bb07ab0 commit 2ff0db1

File tree

22 files changed

+83
-78
lines changed

22 files changed

+83
-78
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
# Data for plotting
1212
t = np.arange(0.0, 2.0, 0.01)
13-
s = 1 + np.sin(2*np.pi*t)
13+
s = 1 + np.sin(2 * np.pi * t)
1414

1515
# Note that using plt.subplots below is equivalent to using
1616
# fig = plt.figure and then ax = fig.add_subplot(111)

examples/pylab_examples/table_demo.py renamed to examples/misc/table_demo.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
import matplotlib.pyplot as plt
1010

1111

12-
data = [[ 66386, 174296, 75131, 577908, 32015],
13-
[ 58230, 381139, 78045, 99308, 160454],
14-
[ 89135, 80552, 152558, 497981, 603535],
15-
[ 78415, 81858, 150656, 193263, 69638],
16-
[ 139361, 331509, 343164, 781380, 52269]]
12+
data = [[ 66386, 174296, 75131, 577908, 32015],
13+
[ 58230, 381139, 78045, 99308, 160454],
14+
[ 89135, 80552, 152558, 497981, 603535],
15+
[ 78415, 81858, 150656, 193263, 69638],
16+
[139361, 331509, 343164, 781380, 52269]]
1717

1818
columns = ('Freeze', 'Wind', 'Flood', 'Quake', 'Hail')
1919
rows = ['%d year' % x for x in (100, 50, 20, 10, 5)]
@@ -36,7 +36,7 @@
3636
for row in range(n_rows):
3737
plt.bar(index, data[row], bar_width, bottom=y_offset, color=colors[row])
3838
y_offset = y_offset + data[row]
39-
cell_text.append(['%1.1f' % (x/1000.0) for x in y_offset])
39+
cell_text.append(['%1.1f' % (x / 1000.0) for x in y_offset])
4040
# Reverse colors and text labels to display the last value at the top.
4141
colors = colors[::-1]
4242
cell_text.reverse()

examples/pylab_examples/pie_demo2.py renamed to examples/pie_and_polar_charts/pie_demo2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
=========
55
66
Make a pie charts of varying size - see
7-
http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.pie for the docstring.
7+
https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.pie for the
8+
docstring.
89
910
This example shows a basic pie charts with labels optional features,
1011
like autolabeling the percentage, offsetting a slice with "explode"

examples/pylab_examples/polar_demo.py renamed to examples/pie_and_polar_charts/polar_demo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
ax = plt.subplot(111, projection='polar')
1616
ax.plot(theta, r)
1717
ax.set_rmax(2)
18-
ax.set_rticks([0.5, 1, 1.5, 2]) # less radial ticks
19-
ax.set_rlabel_position(-22.5) # get radial labels away from plotted line
18+
ax.set_rticks([0.5, 1, 1.5, 2]) # Less radial ticks
19+
ax.set_rlabel_position(-22.5) # Move radial labels away from plotted line
2020
ax.grid(True)
2121

2222
ax.set_title("A line plot on a polar axis", va='bottom')

examples/pylab_examples/polar_legend.py renamed to examples/pie_and_polar_charts/polar_legend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
projection='polar', facecolor='#d5de9c')
2020

2121
r = np.arange(0, 3.0, 0.01)
22-
theta = 2*np.pi*r
22+
theta = 2 * np.pi * r
2323
ax.plot(theta, r, color='#ee8d18', lw=3, label='a line')
24-
ax.plot(0.5*theta, r, color='blue', ls='--', lw=3, label='another line')
24+
ax.plot(0.5 * theta, r, color='blue', ls='--', lw=3, label='another line')
2525
ax.legend()
2626

2727
show()

examples/pylab_examples/log_bar.py renamed to examples/scales/log_bar.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,27 @@
33
Log Bar
44
=======
55
6+
Plotting a bar chart with a logarithmic y-axis.
67
"""
78
import matplotlib.pyplot as plt
89
import numpy as np
910

1011
data = ((3, 1000), (10, 3), (100, 30), (500, 800), (50, 1))
1112

12-
plt.xlabel("FOO")
13-
plt.ylabel("FOO")
14-
plt.title("Testing")
15-
plt.yscale('log')
16-
1713
dim = len(data[0])
1814
w = 0.75
1915
dimw = w / dim
2016

17+
fig, ax = plt.subplots()
2118
x = np.arange(len(data))
2219
for i in range(len(data[0])):
2320
y = [d[i] for d in data]
24-
b = plt.bar(x + i * dimw, y, dimw, bottom=0.001)
21+
b = ax.bar(x + i * dimw, y, dimw, bottom=0.001)
22+
23+
ax.set_xticks(x + dimw / 2, map(str, x))
24+
ax.set_yscale('log')
2525

26-
plt.xticks(x + dimw / 2, map(str, x))
26+
ax.set_xlabel('x')
27+
ax.set_ylabel('y')
2728

2829
plt.show()

examples/pylab_examples/log_demo.py renamed to examples/scales/log_demo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@
2020
fig.subplots_adjust(hspace=0.5)
2121

2222
# log y axis
23-
ax1.semilogy(t, np.exp(-t/5.0))
23+
ax1.semilogy(t, np.exp(-t / 5.0))
2424
ax1.set(title='semilogy')
2525
ax1.grid()
2626

2727
# log x axis
28-
ax2.semilogx(t, np.sin(2*np.pi*t))
28+
ax2.semilogx(t, np.sin(2 * np.pi * t))
2929
ax2.set(title='semilogx')
3030
ax2.grid()
3131

3232
# log x and y axis
33-
ax3.loglog(t, 20*np.exp(-t/10.0), basex=2)
33+
ax3.loglog(t, 20 * np.exp(-t / 10.0), basex=2)
3434
ax3.set(title='loglog base 2 on x')
3535
ax3.grid()
3636

@@ -42,7 +42,7 @@
4242
ax4.set_xscale("log", nonposx='clip')
4343
ax4.set_yscale("log", nonposy='clip')
4444
ax4.set(title='Errorbars go negative')
45-
ax4.errorbar(x, y, xerr=0.1*x, yerr=5.0 + 0.75*y)
45+
ax4.errorbar(x, y, xerr=0.1 * x, yerr=5.0 + 0.75 * y)
4646
# ylim must be set after errorbar to allow errorbar to autoscale limits
4747
ax4.set_ylim(ymin=0.1)
4848

File renamed without changes.

examples/pylab_examples/ellipse_collection.py renamed to examples/shapes_and_collections/ellipse_collection.py

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

1515
XY = np.hstack((X.ravel()[:, np.newaxis], Y.ravel()[:, np.newaxis]))
1616

17-
ww = X/10.0
18-
hh = Y/15.0
19-
aa = X*9
17+
ww = X / 10.0
18+
hh = Y / 15.0
19+
aa = X * 9
2020

2121

2222
fig, ax = plt.subplots()

examples/pylab_examples/ellipse_demo.py renamed to examples/shapes_and_collections/ellipse_demo.py

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

1111
NUM = 250
1212

13-
ells = [Ellipse(xy=np.random.rand(2)*10,
13+
ells = [Ellipse(xy=np.random.rand(2) * 10,
1414
width=np.random.rand(), height=np.random.rand(),
15-
angle=np.random.rand()*360)
15+
angle=np.random.rand() * 360)
1616
for i in range(NUM)]
1717

1818
fig, ax = plt.subplots(subplot_kw={'aspect': 'equal'})

examples/pylab_examples/fancybox_demo.py renamed to examples/shapes_and_collections/fancybox_demo.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
spacing = 1.2
2121

2222
figheight = (spacing * len(styles) + .5)
23-
fig1 = plt.figure(1, (4/1.5, figheight/1.5))
23+
fig1 = plt.figure(1, (4 / 1.5, figheight / 1.5))
2424
fontsize = 0.3 * 72
2525

2626
for i, stylename in enumerate(sorted(styles)):
@@ -65,8 +65,8 @@ def test1(ax):
6565
size=10, transform=ax.transAxes)
6666

6767
# draws control points for the fancy box.
68-
#l = p_fancy.get_path().vertices
69-
#ax.plot(l[:,0], l[:,1], ".")
68+
# l = p_fancy.get_path().vertices
69+
# ax.plot(l[:,0], l[:,1], ".")
7070

7171
# draw the original bbox in black
7272
draw_bbox(ax, bb)
@@ -90,15 +90,15 @@ def test2(ax):
9090

9191
p_fancy.set_boxstyle("round,pad=0.1, rounding_size=0.2")
9292
# or
93-
#p_fancy.set_boxstyle("round", pad=0.1, rounding_size=0.2)
93+
# p_fancy.set_boxstyle("round", pad=0.1, rounding_size=0.2)
9494

9595
ax.text(0.1, 0.8,
9696
' boxstyle="round,pad=0.1\n rounding_size=0.2"',
9797
size=10, transform=ax.transAxes)
9898

9999
# draws control points for the fancy box.
100-
#l = p_fancy.get_path().vertices
101-
#ax.plot(l[:,0], l[:,1], ".")
100+
# l = p_fancy.get_path().vertices
101+
# ax.plot(l[:,0], l[:,1], ".")
102102

103103
draw_bbox(ax, bb)
104104

@@ -122,8 +122,8 @@ def test3(ax):
122122
size=10, transform=ax.transAxes)
123123

124124
# draws control points for the fancy box.
125-
#l = p_fancy.get_path().vertices
126-
#ax.plot(l[:,0], l[:,1], ".")
125+
# l = p_fancy.get_path().vertices
126+
# ax.plot(l[:,0], l[:,1], ".")
127127

128128
draw_bbox(ax, bb)
129129

@@ -192,4 +192,5 @@ def test_all():
192192
plt.draw()
193193
plt.show()
194194

195+
195196
test_all()

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

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def bullseye_plot(ax, data, segBold=None, cmap=None, norm=None):
5454
if norm is None:
5555
norm = mpl.colors.Normalize(vmin=data.min(), vmax=data.max())
5656

57-
theta = np.linspace(0, 2*np.pi, 768)
57+
theta = np.linspace(0, 2 * np.pi, 768)
5858
r = np.linspace(0.2, 1, 4)
5959

6060
# Create the bound for the segment 17
@@ -76,52 +76,52 @@ def bullseye_plot(ax, data, segBold=None, cmap=None, norm=None):
7676
r0 = np.repeat(r0[:, np.newaxis], 128, axis=1).T
7777
for i in range(6):
7878
# First segment start at 60 degrees
79-
theta0 = theta[i*128:i*128+128] + np.deg2rad(60)
79+
theta0 = theta[i * 128:i * 128 + 128] + np.deg2rad(60)
8080
theta0 = np.repeat(theta0[:, np.newaxis], 2, axis=1)
81-
z = np.ones((128, 2))*data[i]
81+
z = np.ones((128, 2)) * data[i]
8282
ax.pcolormesh(theta0, r0, z, cmap=cmap, norm=norm)
83-
if i+1 in segBold:
84-
ax.plot(theta0, r0, '-k', lw=linewidth+2)
85-
ax.plot(theta0[0], [r[2], r[3]], '-k', lw=linewidth+1)
86-
ax.plot(theta0[-1], [r[2], r[3]], '-k', lw=linewidth+1)
83+
if i + 1 in segBold:
84+
ax.plot(theta0, r0, '-k', lw=linewidth + 2)
85+
ax.plot(theta0[0], [r[2], r[3]], '-k', lw=linewidth + 1)
86+
ax.plot(theta0[-1], [r[2], r[3]], '-k', lw=linewidth + 1)
8787

8888
# Fill the segments 7-12
8989
r0 = r[1:3]
9090
r0 = np.repeat(r0[:, np.newaxis], 128, axis=1).T
9191
for i in range(6):
9292
# First segment start at 60 degrees
93-
theta0 = theta[i*128:i*128+128] + np.deg2rad(60)
93+
theta0 = theta[i * 128:i * 128 + 128] + np.deg2rad(60)
9494
theta0 = np.repeat(theta0[:, np.newaxis], 2, axis=1)
95-
z = np.ones((128, 2))*data[i+6]
95+
z = np.ones((128, 2)) * data[i + 6]
9696
ax.pcolormesh(theta0, r0, z, cmap=cmap, norm=norm)
97-
if i+7 in segBold:
98-
ax.plot(theta0, r0, '-k', lw=linewidth+2)
99-
ax.plot(theta0[0], [r[1], r[2]], '-k', lw=linewidth+1)
100-
ax.plot(theta0[-1], [r[1], r[2]], '-k', lw=linewidth+1)
97+
if i + 7 in segBold:
98+
ax.plot(theta0, r0, '-k', lw=linewidth + 2)
99+
ax.plot(theta0[0], [r[1], r[2]], '-k', lw=linewidth + 1)
100+
ax.plot(theta0[-1], [r[1], r[2]], '-k', lw=linewidth + 1)
101101

102102
# Fill the segments 13-16
103103
r0 = r[0:2]
104104
r0 = np.repeat(r0[:, np.newaxis], 192, axis=1).T
105105
for i in range(4):
106106
# First segment start at 45 degrees
107-
theta0 = theta[i*192:i*192+192] + np.deg2rad(45)
107+
theta0 = theta[i * 192:i * 192 + 192] + np.deg2rad(45)
108108
theta0 = np.repeat(theta0[:, np.newaxis], 2, axis=1)
109-
z = np.ones((192, 2))*data[i+12]
109+
z = np.ones((192, 2)) * data[i + 12]
110110
ax.pcolormesh(theta0, r0, z, cmap=cmap, norm=norm)
111-
if i+13 in segBold:
112-
ax.plot(theta0, r0, '-k', lw=linewidth+2)
113-
ax.plot(theta0[0], [r[0], r[1]], '-k', lw=linewidth+1)
114-
ax.plot(theta0[-1], [r[0], r[1]], '-k', lw=linewidth+1)
111+
if i + 13 in segBold:
112+
ax.plot(theta0, r0, '-k', lw=linewidth + 2)
113+
ax.plot(theta0[0], [r[0], r[1]], '-k', lw=linewidth + 1)
114+
ax.plot(theta0[-1], [r[0], r[1]], '-k', lw=linewidth + 1)
115115

116116
# Fill the segments 17
117117
if data.size == 17:
118118
r0 = np.array([0, r[0]])
119119
r0 = np.repeat(r0[:, np.newaxis], theta.size, axis=1).T
120120
theta0 = np.repeat(theta[:, np.newaxis], 2, axis=1)
121-
z = np.ones((theta.size, 2))*data[16]
121+
z = np.ones((theta.size, 2)) * data[16]
122122
ax.pcolormesh(theta0, r0, z, cmap=cmap, norm=norm)
123123
if 17 in segBold:
124-
ax.plot(theta0, r0, '-k', lw=linewidth+2)
124+
ax.plot(theta0, r0, '-k', lw=linewidth + 2)
125125

126126
ax.set_ylim([0, 1])
127127
ax.set_yticklabels([])
@@ -188,7 +188,7 @@ def bullseye_plot(ax, data, segBold=None, cmap=None, norm=None):
188188
cb3 = mpl.colorbar.ColorbarBase(axl3, cmap=cmap3, norm=norm3,
189189
# to use 'extend', you must
190190
# specify two extra boundaries:
191-
boundaries=[0]+bounds+[18],
191+
boundaries=[0] + bounds + [18],
192192
extend='both',
193193
ticks=bounds, # optional
194194
spacing='proportional',

examples/pylab_examples/figlegend_demo.py renamed to examples/text_labels_and_annotations/figlegend_demo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
fig, axs = plt.subplots(1, 2)
1414

1515
x = np.arange(0.0, 2.0, 0.02)
16-
y1 = np.sin(2*np.pi*x)
16+
y1 = np.sin(2 * np.pi * x)
1717
y2 = np.exp(-x)
1818
l1, l2 = axs[0].plot(x, y1, 'rs-', x, y2, 'go')
1919

20-
y3 = np.sin(4*np.pi*x)
21-
y4 = np.exp(-2*x)
20+
y3 = np.sin(4 * np.pi * x)
21+
y4 = np.exp(-2 * x)
2222
l3, l4 = axs[1].plot(x, y3, 'yd-', x, y4, 'k^')
2323

2424
fig.legend((l1, l2), ('Line 1', 'Line 2'), 'upper left')

examples/pylab_examples/usetex_fonteffects.py renamed to examples/text_labels_and_annotations/usetex_fonteffects.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
def setfont(font):
1616
return r'\font\a %s at 14pt\a ' % font
1717

18+
1819
for y, font, text in zip(range(5),
19-
['ptmr8r', 'ptmri8r', 'ptmro8r', 'ptmr8rn', 'ptmrr8re'],
20+
['ptmr8r', 'ptmri8r', 'ptmro8r',
21+
'ptmr8rn', 'ptmrr8re'],
2022
['Nimbus Roman No9 L ' + x for x in
2123
['', 'Italics (real italics for comparison)',
2224
'(slanted)', '(condensed)', '(extended)']]):

examples/pylab_examples/major_minor_demo.py renamed to examples/ticks_and_spines/major_minor_demo.py

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

4545

4646
t = np.arange(0.0, 100.0, 0.1)
47-
s = np.sin(0.1*np.pi*t)*np.exp(-t*0.01)
47+
s = np.sin(0.1 * np.pi * t) * np.exp(-t * 0.01)
4848

4949
fig, ax = plt.subplots()
5050
ax.plot(t, s)
@@ -73,7 +73,7 @@
7373

7474

7575
t = np.arange(0.0, 100.0, 0.01)
76-
s = np.sin(2*np.pi*t)*np.exp(-t*0.01)
76+
s = np.sin(2 * np.pi * t) * np.exp(-t * 0.01)
7777

7878
fig, ax = plt.subplots()
7979
ax.plot(t, s)

lib/matplotlib/ticker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
ax.yaxis.set_major_formatter( ymajorFormatter )
164164
ax.yaxis.set_minor_formatter( yminorFormatter )
165165
166-
See :ref:`sphx_glr_gallery_pylab_examples_major_minor_demo.py` for an
166+
See :ref:`sphx_glr_gallery_ticks_and_spines_major_minor_demo.py` for an
167167
example of setting major and minor ticks. See the :mod:`matplotlib.dates`
168168
module for more information and examples of using date locators and formatters.
169169
"""

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pep8ignore =
115115
tutorials/* E402 E501
116116

117117
*examples/* E501 E402
118-
*examples/pylab_examples/table_demo.py E201
118+
*examples/misc/table_demo.py E201
119119
*examples/images_contours_and_fields/tricontour_demo.py E201
120120
*examples/images_contours_and_fields/tripcolor_demo.py E201
121121
*examples/images_contours_and_fields/triplot_demo.py E201

0 commit comments

Comments
 (0)