Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6b84212

Browse filesBrowse files
committed
Cleanup plot types
1 parent 4f2f4de commit 6b84212
Copy full SHA for 6b84212
Expand file treeCollapse file tree

20 files changed

+60
-61
lines changed

‎plot_types/arrays/contourf.py

Copy file name to clipboardExpand all lines: plot_types/arrays/contourf.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212

1313
# make data
1414
X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256))
15-
Z = (1 - X/2. + X**5 + Y**3)*np.exp(-X**2-Y**2)
15+
Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2)
1616
Z = Z - Z.min()
17-
levs = np.linspace(np.min(Z), np.max(Z), 7)
17+
levels = np.linspace(np.min(Z), np.max(Z), 7)
1818

1919
# plot
2020
fig, ax = plt.subplots()
2121

22-
plt.contourf(X, Y, Z, levels=levs)
23-
plt.contour(X, Y, Z, levels=levs, colors="white", linewidths=0.5)
22+
ax.contourf(X, Y, Z, levels=levels)
23+
ax.contour(X, Y, Z, levels=levels, colors="white", linewidths=0.5)
2424

2525
plt.show()

‎plot_types/arrays/imshow.py

Copy file name to clipboardExpand all lines: plot_types/arrays/imshow.py
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@
1919

2020
# plot
2121
fig, ax = plt.subplots()
22+
ax.grid(False)
2223

23-
ax.imshow(Z, extent=[0, 8, 0, 8], interpolation="nearest",
24-
cmap=plt.get_cmap('Blues'), vmin=0, vmax=1.6)
25-
26-
ax.set(xticks=[], yticks=[])
24+
ax.imshow(Z)
2725

2826
plt.show()

‎plot_types/arrays/pcolormesh.py

Copy file name to clipboardExpand all lines: plot_types/arrays/pcolormesh.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727

2828
# plot
2929
fig, ax = plt.subplots()
30+
ax.grid(False)
3031

31-
ax.pcolormesh(X, Y, Z, vmin=0, vmax=1.5, shading='nearest')
32+
ax.pcolormesh(X, Y, Z, vmin=0, vmax=1.5)
3233

3334
plt.show()

‎plot_types/arrays/quiver.py

Copy file name to clipboardExpand all lines: plot_types/arrays/quiver.py
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
plt.style.use('mpl_plot_gallery')
1212

1313
# make data
14-
T = np.linspace(0, 2*np.pi, 8)
15-
X, Y = 4 + 1 * np.cos(T), 4 + 1 * np.sin(T)
16-
U, V = 1.5 * np.cos(T), 1.5 * np.sin(T)
14+
phi = np.linspace(0, 2 * np.pi, 8)
15+
x, y = 4 + 1 * np.cos(phi), 4 + 1 * np.sin(phi)
16+
u, v = 1.5 * np.cos(phi), 1.5 * np.sin(phi)
1717

1818
# plot
1919
fig, ax = plt.subplots()
2020

21-
plt.quiver(X, Y, U, V, color="C0", angles='xy',
22-
scale_units='xy', scale=0.5, width=.05)
21+
ax.quiver(x, y, u, v, color="C0", angles='xy',
22+
scale_units='xy', scale=0.5, width=.05)
2323

2424
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
2525
ylim=(0, 8), yticks=np.arange(1, 8))

‎plot_types/basic/bar.py

Copy file name to clipboardExpand all lines: plot_types/basic/bar.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111

1212
# make data:
1313
np.random.seed(3)
14-
X = 0.5 + np.arange(8)
15-
Y = np.random.uniform(2, 7, len(X))
14+
x = 0.5 + np.arange(8)
15+
y = np.random.uniform(2, 7, len(x))
1616

1717
# plot
1818
fig, ax = plt.subplots()
1919

20-
ax.bar(X, Y, width=1, edgecolor="white", linewidth=0.7)
20+
ax.bar(x, y, width=1, edgecolor="white", linewidth=0.7)
2121

2222
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
2323
ylim=(0, 8), yticks=np.arange(1, 8))

‎plot_types/basic/pie.py

Copy file name to clipboardExpand all lines: plot_types/basic/pie.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313

1414
# make data
15-
X = [1, 2, 3, 4]
16-
colors = plt.get_cmap('Blues')(np.linspace(0.2, 0.7, len(X)))
15+
x = [1, 2, 3, 4]
16+
colors = plt.get_cmap('Blues')(np.linspace(0.2, 0.7, len(x)))
1717

1818
# plot
1919
fig, ax = plt.subplots()
20-
ax.pie(X, colors=colors, radius=3, center=(4, 4),
20+
ax.pie(x, colors=colors, radius=3, center=(4, 4),
2121
wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True)
2222

2323
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),

‎plot_types/basic/plot.py

Copy file name to clipboardExpand all lines: plot_types/basic/plot.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
plt.style.use('mpl_plot_gallery')
1313

1414
# make data
15-
X = np.linspace(0, 10, 100)
16-
Y = 4 + 2 * np.sin(2 * X)
15+
x = np.linspace(0, 10, 100)
16+
y = 4 + 2 * np.sin(2 * x)
1717

1818
# plot
1919
fig, ax = plt.subplots()
2020

21-
ax.plot(X, Y, linewidth=2.0)
21+
ax.plot(x, y, linewidth=2.0)
2222

2323
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
2424
ylim=(0, 8), yticks=np.arange(1, 8))

‎plot_types/basic/scatter_plot.py

Copy file name to clipboardExpand all lines: plot_types/basic/scatter_plot.py
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212

1313
# make the data
1414
np.random.seed(3)
15-
X = 4 + np.random.normal(0, 2, 24)
16-
Y = 4 + np.random.normal(0, 2, len(X))
15+
x = 4 + np.random.normal(0, 2, 24)
16+
y = 4 + np.random.normal(0, 2, len(x))
1717
# size and color:
18-
S = np.random.uniform(15, 80, len(X))
18+
sizes = np.random.uniform(15, 80, len(x))
19+
colors = np.random.uniform(15, 80, len(x))
1920

2021
# plot
2122
fig, ax = plt.subplots()
2223

23-
ax.scatter(X, Y, s=S, c=-S, cmap=plt.get_cmap('Blues'), vmin=-100, vmax=0)
24+
ax.scatter(x, y, s=sizes, c=colors, vmin=-100, vmax=0)
2425

2526
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
2627
ylim=(0, 8), yticks=np.arange(1, 8))

‎plot_types/basic/stem.py

Copy file name to clipboardExpand all lines: plot_types/basic/stem.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
# make data
1414
np.random.seed(3)
15-
X = 0.5 + np.arange(8)
16-
Y = np.random.uniform(2, 7, len(X))
15+
x = 0.5 + np.arange(8)
16+
y = np.random.uniform(2, 7, len(x))
1717

1818
# plot
1919
fig, ax = plt.subplots()
2020

21-
ax.stem(X, Y, bottom=0, linefmt="-", markerfmt="d")
21+
ax.stem(x, y)
2222

2323
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
2424
ylim=(0, 8), yticks=np.arange(1, 8))

‎plot_types/basic/step.py

Copy file name to clipboardExpand all lines: plot_types/basic/step.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
# make data
1414
np.random.seed(3)
15-
X = 0.5 + np.arange(8)
16-
Y = np.random.uniform(2, 7, len(X))
15+
x = 0.5 + np.arange(8)
16+
y = np.random.uniform(2, 7, len(x))
1717

1818
# plot
1919
fig, ax = plt.subplots()
2020

21-
ax.step(X, Y, linewidth=2.5)
21+
ax.step(x, y, linewidth=2.5)
2222

2323
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
2424
ylim=(0, 8), yticks=np.arange(1, 8))

‎plot_types/stats/barbs.py

Copy file name to clipboardExpand all lines: plot_types/stats/barbs.py
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
np.random.seed(1)
1515
X = [[2, 4, 6]]
1616
Y = [[1.5, 3, 2]]
17-
U = -np.ones((1, 3)) * 0
18-
V = -np.ones((1, 3)) * np.linspace(50, 100, 3)
17+
U = np.zeros_like(X)
18+
V = -np.ones_like(X) * np.linspace(50, 100, 3)
1919

2020
# plot:
2121
fig, ax = plt.subplots()
2222

23-
ax.barbs(X, Y, U, V, barbcolor="C0", flagcolor="C0",
24-
length=10, linewidth=1.5)
23+
ax.barbs(X, Y, U, V, barbcolor="C0", flagcolor="C0", length=10, linewidth=1.5)
2524

2625
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
2726
ylim=(0, 8), yticks=np.arange(1, 8))

‎plot_types/stats/errorbar_plot.py

Copy file name to clipboardExpand all lines: plot_types/stats/errorbar_plot.py
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
==========================
3-
errorbar(X, Y, xerr, yerr)
3+
errorbar(x, y, yerr, xerr)
44
==========================
55
66
See `~matplotlib.axes.Axes.errorbar`.
@@ -12,14 +12,14 @@
1212

1313
# make data:
1414
np.random.seed(1)
15-
X = [2, 4, 6]
16-
Y = [4, 5, 4]
17-
E = np.random.uniform(0.5, 1.5, 3)
15+
x = [2, 4, 6]
16+
y = [4, 5, 4]
17+
yerr = np.random.uniform(0.5, 1.5, 3)
1818

1919
# plot:
2020
fig, ax = plt.subplots()
2121

22-
ax.errorbar(X, Y, E, linewidth=2, capsize=6)
22+
ax.errorbar(x, y, yerr, linewidth=2, capsize=6)
2323

2424
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
2525
ylim=(0, 8), yticks=np.arange(1, 8))

‎plot_types/stats/eventplot.py

Copy file name to clipboardExpand all lines: plot_types/stats/eventplot.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
# make data:
1414
np.random.seed(1)
15-
X = [2, 4, 6]
15+
x = [2, 4, 6]
1616
D = np.random.gamma(4, size=(3, 50))
1717

1818
# plot:
1919
fig, ax = plt.subplots()
2020

21-
ax.eventplot(D, orientation="vertical", lineoffsets=X, linewidth=0.75)
21+
ax.eventplot(D, orientation="vertical", lineoffsets=x, linewidth=0.75)
2222

2323
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
2424
ylim=(0, 8), yticks=np.arange(1, 8))

‎plot_types/stats/hexbin.py

Copy file name to clipboardExpand all lines: plot_types/stats/hexbin.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# make data: correlated + noise
1414
np.random.seed(1)
1515
x = np.random.randn(5000)
16-
y = 1.2 * x + np.random.randn(5000)/3
16+
y = 1.2 * x + np.random.randn(5000) / 3
1717

1818
# plot:
1919
fig, ax = plt.subplots()

‎plot_types/stats/hist2d.py

Copy file name to clipboardExpand all lines: plot_types/stats/hist2d.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# make data: correlated + noise
1414
np.random.seed(1)
1515
x = np.random.randn(5000)
16-
y = 1.2 * x + np.random.randn(5000)/3
16+
y = 1.2 * x + np.random.randn(5000) / 3
1717

1818
# plot:
1919
fig, ax = plt.subplots()

‎plot_types/stats/hist_plot.py

Copy file name to clipboardExpand all lines: plot_types/stats/hist_plot.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
=======
3-
hist(X)
3+
hist(x)
44
=======
55
66
See `~matplotlib.axes.Axes.hist`.
@@ -12,12 +12,12 @@
1212

1313
# make data
1414
np.random.seed(1)
15-
X = 4 + np.random.normal(0, 1.5, 200)
15+
x = 4 + np.random.normal(0, 1.5, 200)
1616

1717
# plot:
1818
fig, ax = plt.subplots()
1919

20-
ax.hist(X, bins=8, linewidth=0.5, edgecolor="white")
20+
ax.hist(x, bins=8, linewidth=0.5, edgecolor="white")
2121

2222
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
2323
ylim=(0, 8), yticks=np.arange(1, 8))

‎plot_types/stats/violin.py

Copy file name to clipboardExpand all lines: plot_types/stats/violin.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
# plot:
1818
fig, ax = plt.subplots()
1919

20-
VP = ax.violinplot(D, [2, 4, 6], widths=2,
21-
showmeans=False, showmedians=False, showextrema=False)
20+
vp = ax.violinplot(D, [2, 4, 6], widths=2,
21+
showmeans=False, showmedians=False, showextrema=False)
2222
# styling:
23-
for body in VP['bodies']:
23+
for body in vp['bodies']:
2424
body.set_alpha(0.9)
2525
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
2626
ylim=(0, 8), yticks=np.arange(1, 8))

‎plot_types/unstructured/tricontour.py

Copy file name to clipboardExpand all lines: plot_types/unstructured/tricontour.py
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
# make structured data
1414
X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256))
15-
Z = (1 - X/2. + X**5 + Y**3)*np.exp(-X**2-Y**2)
15+
Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2)
1616
Z = Z - Z.min()
1717

1818
# sample it to make unstructured x, y, z
1919
np.random.seed(1)
20-
ysamp = np.random.randint(0, high=256, size=250)
21-
xsamp = np.random.randint(0, high=256, size=250)
20+
ysamp = np.random.randint(0, 256, size=250)
21+
xsamp = np.random.randint(0, 256, size=250)
2222
y = Y[:, 0][ysamp]
2323
x = X[0, :][xsamp]
2424
z = Z[ysamp, xsamp]
@@ -27,8 +27,8 @@
2727
fig, ax = plt.subplots()
2828

2929
ax.plot(x, y, '.k', alpha=0.5)
30-
levs = np.linspace(np.min(Z), np.max(Z), 7)
31-
ax.tricontourf(x, y, z, levels=levs)
30+
levels = np.linspace(np.min(Z), np.max(Z), 7)
31+
ax.tricontourf(x, y, z, levels=levels)
3232

3333
ax.set(xlim=(-3, 3), ylim=(-3, 3))
3434

‎plot_types/unstructured/tripcolor.py

Copy file name to clipboardExpand all lines: plot_types/unstructured/tripcolor.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
# sample it to make unstructured x, y, z
1919
np.random.seed(1)
20-
ysamp = np.random.randint(0, high=256, size=250)
21-
xsamp = np.random.randint(0, high=256, size=250)
20+
ysamp = np.random.randint(0, 256, size=250)
21+
xsamp = np.random.randint(0, 256, size=250)
2222
y = Y[:, 0][ysamp]
2323
x = X[0, :][xsamp]
2424
z = Z[ysamp, xsamp]

‎plot_types/unstructured/triplot.py

Copy file name to clipboardExpand all lines: plot_types/unstructured/triplot.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
# sample it to make x, y, z
1717
np.random.seed(1)
18-
ysamp = np.random.randint(0, high=256, size=250)
19-
xsamp = np.random.randint(0, high=256, size=250)
18+
ysamp = np.random.randint(0, 256, size=250)
19+
xsamp = np.random.randint(0, 256, size=250)
2020
y = Y[:, 0][ysamp]
2121
x = X[0, :][xsamp]
2222

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.