Skip to content

Commit b2b2f36

Browse files
authored
Merge pull request matplotlib#21123 from anntzer/ptm
Simplify/uniformize sample data setup in plot_types examples.
2 parents 820cf1f + 834a467 commit b2b2f36

File tree

5 files changed

+4
-9
lines changed

5 files changed

+4
-9
lines changed

plot_types/arrays/contourf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
# make data
1414
X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256))
1515
Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2)
16-
Z = Z - Z.min()
17-
levels = np.linspace(np.min(Z), np.max(Z), 7)
16+
levels = np.linspace(Z.min(), Z.max(), 7)
1817

1918
# plot
2019
fig, ax = plt.subplots()

plot_types/arrays/imshow.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# make data
1515
X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256))
1616
Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2)
17-
Z = Z - Z.min()
1817
Z = Z[::16, ::16]
1918

2019
# plot

plot_types/arrays/pcolormesh.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# make full-res data
1616
X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256))
1717
Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2)
18-
Z = Z - Z.min()
1918

2019
# sample unevenly in x:
2120
dx = np.sqrt((np.arange(16) - 8)**2) + 6
@@ -29,6 +28,6 @@
2928
fig, ax = plt.subplots()
3029
ax.grid(False)
3130

32-
ax.pcolormesh(X, Y, Z, vmin=0, vmax=1.5)
31+
ax.pcolormesh(X, Y, Z, vmin=-0.5, vmax=1.0)
3332

3433
plt.show()

plot_types/unstructured/tricontour.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# make structured data
1414
X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256))
1515
Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2)
16-
Z = Z - Z.min()
1716

1817
# sample it to make unstructured x, y, z
1918
np.random.seed(1)
@@ -27,7 +26,7 @@
2726
fig, ax = plt.subplots()
2827

2928
ax.plot(x, y, '.k', alpha=0.5)
30-
levels = np.linspace(np.min(Z), np.max(Z), 7)
29+
levels = np.linspace(Z.min(), Z.max(), 7)
3130
ax.tricontourf(x, y, z, levels=levels)
3231

3332
ax.set(xlim=(-3, 3), ylim=(-3, 3))

plot_types/unstructured/tripcolor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
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)
16-
Z = Z - Z.min()
15+
Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2)
1716

1817
# sample it to make unstructured x, y, z
1918
np.random.seed(1)

0 commit comments

Comments
 (0)