Skip to content

Commit 2ff0db1

Browse files
authored
Merge pull request matplotlib#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)
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()
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()
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

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'})

0 commit comments

Comments
 (0)