Skip to content

Commit d0b5bdc

Browse files
authored
Merge pull request #21136 from timhoffm/gallery-order
More (minor) plot types gallery fixes.
2 parents 5ef0e5e + 934954a commit d0b5bdc

27 files changed

+67
-78
lines changed

doc/sphinxext/gallery_order.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ def __call__(self, item):
7070
# Basic
7171
"plot", "scatter_plot", "bar", "stem", "step", "pie", "fill_between",
7272
# Arrays
73-
"imshow", "pcolormesh", "contourf", "quiver", "streamplot",
73+
"imshow", "pcolormesh", "contour", "contourf", "quiver", "streamplot",
7474
# Stats
7575
"hist_plot", "boxplot_plot", "errorbar_plot", "violin",
7676
"barbs", "eventplot", "hist2d", "hexbin",
7777
# Unstructured
78-
"tricontour", "tripcolor", "triplot",
78+
"tricontour", "tricontourf", "tripcolor", "triplot",
7979
]
8080
explicit_subsection_order = [item + ".py" for item in list_all]
8181

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# This style is used for the plot_types gallery. It is considered private.
2+
3+
axes.grid: False
4+
axes.axisbelow: True
5+
6+
figure.figsize: 2, 2
7+
# make it so the axes labels don't show up. Obviously
8+
# not good style for any quantitative analysis:
9+
figure.subplot.left: 0.01
10+
figure.subplot.right: 0.99
11+
figure.subplot.bottom: 0.01
12+
figure.subplot.top: 0.99
13+
14+
xtick.major.size: 0.0
15+
ytick.major.size: 0.0
16+
17+
# colors:
18+
image.cmap : Blues
19+
# axes.prop_cycle: cycler('color', ['FF7F0E', '1F77B4', '2CA02C'])

lib/matplotlib/mpl-data/stylelib/mpl_plot_gallery.mplstyle renamed to lib/matplotlib/mpl-data/stylelib/_mpl-gallery.mplstyle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# from the Matplotlib cheatsheet as used in our gallery:
1+
# This style is used for the plot_types gallery. It is considered part of the private API.
22

33
axes.grid: True
44
axes.axisbelow: True

plot_types/arrays/contour.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
plt.style.use('mpl_plot_gallery')
11+
plt.style.use('_mpl-gallery-nogrid')
1212

1313
# make data
1414
X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256))
@@ -17,7 +17,6 @@
1717

1818
# plot
1919
fig, ax = plt.subplots()
20-
ax.grid(False)
2120

2221
ax.contour(X, Y, Z, levels=levels)
2322

plot_types/arrays/contourf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
plt.style.use('mpl_plot_gallery')
11+
plt.style.use('_mpl-gallery-nogrid')
1212

1313
# make data
1414
X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256))

plot_types/arrays/imshow.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@
99
import matplotlib.pyplot as plt
1010
import numpy as np
1111

12-
plt.style.use('mpl_plot_gallery')
12+
plt.style.use('_mpl-gallery-nogrid')
1313

1414
# make data
1515
X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256))
16-
Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2)
16+
Z = (1 - X/2 + X**5 + Y**3) * np.exp(-X**2 - Y**2)
1717
Z = Z[::16, ::16]
1818

1919
# plot
2020
fig, ax = plt.subplots()
21-
ax.grid(False)
2221

2322
ax.imshow(Z)
2423

plot_types/arrays/pcolormesh.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
import matplotlib.pyplot as plt
1111
import numpy as np
1212

13-
plt.style.use('mpl_plot_gallery')
13+
plt.style.use('_mpl-gallery-nogrid')
1414

1515
# make full-res data
1616
X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256))
17-
Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2)
17+
Z = (1 - X/2 + X**5 + Y**3) * np.exp(-X**2 - Y**2)
1818

1919
# sample unevenly in x:
2020
dx = np.sqrt((np.arange(16) - 8)**2) + 6
@@ -26,7 +26,6 @@
2626

2727
# plot
2828
fig, ax = plt.subplots()
29-
ax.grid(False)
3029

3130
ax.pcolormesh(X, Y, Z, vmin=-0.5, vmax=1.0)
3231

plot_types/arrays/quiver.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
plt.style.use('mpl_plot_gallery')
11+
plt.style.use('_mpl-gallery')
1212

1313
# make data
1414
phi = np.linspace(0, 2 * np.pi, 8)

plot_types/arrays/streamplot.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,18 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
plt.style.use('mpl_plot_gallery')
11+
plt.style.use('_mpl-gallery-nogrid')
1212

1313
# make a stream function:
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
# make U and V out of the streamfunction:
1717
V = np.diff(Z[1:, :], axis=1)
1818
U = -np.diff(Z[:, 1:], axis=0)
1919

2020
# plot:
2121
fig, ax = plt.subplots()
22-
ax.grid(False)
2322

24-
# plot stream plot
2523
ax.streamplot(X[1:, 1:], Y[1:, 1:], U, V)
2624

2725
plt.show()

plot_types/basic/bar.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88
import matplotlib.pyplot as plt
99
import numpy as np
10-
plt.style.use('mpl_plot_gallery')
10+
plt.style.use('_mpl-gallery')
1111

1212
# make data:
1313
np.random.seed(3)

plot_types/basic/pie.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
plt.style.use('mpl_plot_gallery')
11+
plt.style.use('_mpl-gallery-nogrid')
1212

1313

1414
# make data

plot_types/basic/plot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import matplotlib.pyplot as plt
1010
import numpy as np
1111

12-
plt.style.use('mpl_plot_gallery')
12+
plt.style.use('_mpl-gallery')
1313

1414
# make data
1515
x = np.linspace(0, 10, 100)

plot_types/basic/scatter_plot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
plt.style.use('mpl_plot_gallery')
11+
plt.style.use('_mpl-gallery')
1212

1313
# make the data
1414
np.random.seed(3)

plot_types/basic/stem.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
plt.style.use('mpl_plot_gallery')
11+
plt.style.use('_mpl-gallery')
1212

1313
# make data
1414
np.random.seed(3)

plot_types/basic/step.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
plt.style.use('mpl_plot_gallery')
11+
plt.style.use('_mpl-gallery')
1212

1313
# make data
1414
np.random.seed(3)

plot_types/stats/barbs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
plt.style.use('mpl_plot_gallery')
11+
plt.style.use('_mpl-gallery')
1212

1313
# make data:
1414
np.random.seed(1)

plot_types/stats/boxplot_plot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
plt.style.use('mpl_plot_gallery')
11+
plt.style.use('_mpl-gallery')
1212

1313
# make data:
1414
np.random.seed(10)

plot_types/stats/errorbar_plot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
plt.style.use('mpl_plot_gallery')
11+
plt.style.use('_mpl-gallery')
1212

1313
# make data:
1414
np.random.seed(1)

plot_types/stats/eventplot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
plt.style.use('mpl_plot_gallery')
11+
plt.style.use('_mpl-gallery')
1212

1313
# make data:
1414
np.random.seed(1)

plot_types/stats/hexbin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
plt.style.use('mpl_plot_gallery')
11+
plt.style.use('_mpl-gallery-nogrid')
1212

1313
# make data: correlated + noise
1414
np.random.seed(1)

plot_types/stats/hist2d.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
plt.style.use('mpl_plot_gallery')
11+
plt.style.use('_mpl-gallery-nogrid')
1212

1313
# make data: correlated + noise
1414
np.random.seed(1)

plot_types/stats/hist_plot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
plt.style.use('mpl_plot_gallery')
11+
plt.style.use('_mpl-gallery')
1212

1313
# make data
1414
np.random.seed(1)

plot_types/stats/violin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
plt.style.use('mpl_plot_gallery')
11+
plt.style.use('_mpl-gallery')
1212

1313
# make data:
1414
np.random.seed(10)

plot_types/unstructured/tricontour.py

+6-13
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,17 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
plt.style.use('mpl_plot_gallery')
11+
plt.style.use('_mpl-gallery-nogrid')
1212

13-
# make structured data
14-
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-
levels = np.linspace(Z.min(), Z.max(), 7)
17-
18-
# sample it to make unstructured x, y, z
13+
# make data:
1914
np.random.seed(1)
20-
ysamp = np.random.randint(0, 256, size=250)
21-
xsamp = np.random.randint(0, 256, size=250)
22-
y = Y[:, 0][ysamp]
23-
x = X[0, :][xsamp]
24-
z = Z[ysamp, xsamp]
15+
x = np.random.uniform(-3, 3, 256)
16+
y = np.random.uniform(-3, 3, 256)
17+
z = (1 - x/2 + x**5 + y**3) * np.exp(-x**2 - y**2)
18+
levels = np.linspace(z.min(), z.max(), 7)
2519

2620
# plot:
2721
fig, ax = plt.subplots()
28-
ax.grid(False)
2922

3023
ax.plot(x, y, 'o', markersize=2, color='lightgrey')
3124
ax.tricontour(x, y, z, levels=levels)

plot_types/unstructured/tricontourf.py

+6-13
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,17 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
plt.style.use('mpl_plot_gallery')
11+
plt.style.use('_mpl-gallery-nogrid')
1212

13-
# make structured data
14-
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-
levels = np.linspace(np.min(Z), np.max(Z), 7)
17-
18-
# sample it to make unstructured x, y, z
13+
# make data:
1914
np.random.seed(1)
20-
ysamp = np.random.randint(0, 256, size=250)
21-
xsamp = np.random.randint(0, 256, size=250)
22-
y = Y[:, 0][ysamp]
23-
x = X[0, :][xsamp]
24-
z = Z[ysamp, xsamp]
15+
x = np.random.uniform(-3, 3, 256)
16+
y = np.random.uniform(-3, 3, 256)
17+
z = (1 - x/2 + x**5 + y**3) * np.exp(-x**2 - y**2)
18+
levels = np.linspace(z.min(), z.max(), 7)
2519

2620
# plot:
2721
fig, ax = plt.subplots()
28-
ax.grid(False)
2922

3023
ax.plot(x, y, 'o', markersize=2, color='grey')
3124
ax.tricontourf(x, y, z, levels=levels)

plot_types/unstructured/tripcolor.py

+5-11
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,13 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
plt.style.use('mpl_plot_gallery')
11+
plt.style.use('_mpl-gallery-nogrid')
1212

13-
# make structured data
14-
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-
17-
# sample it to make unstructured x, y, z
13+
# make data:
1814
np.random.seed(1)
19-
ysamp = np.random.randint(0, 256, size=250)
20-
xsamp = np.random.randint(0, 256, size=250)
21-
y = Y[:, 0][ysamp]
22-
x = X[0, :][xsamp]
23-
z = Z[ysamp, xsamp]
15+
x = np.random.uniform(-3, 3, 256)
16+
y = np.random.uniform(-3, 3, 256)
17+
z = (1 - x/2 + x**5 + y**3) * np.exp(-x**2 - y**2)
2418

2519
# plot:
2620
fig, ax = plt.subplots()

plot_types/unstructured/triplot.py

+5-10
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,16 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
plt.style.use('mpl_plot_gallery')
11+
plt.style.use('_mpl-gallery-nogrid')
1212

13-
# make structured data
14-
X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256))
15-
16-
# sample it to make x, y, z
13+
# make data:
1714
np.random.seed(1)
18-
ysamp = np.random.randint(0, 256, size=250)
19-
xsamp = np.random.randint(0, 256, size=250)
20-
y = Y[:, 0][ysamp]
21-
x = X[0, :][xsamp]
15+
x = np.random.uniform(-3, 3, 256)
16+
y = np.random.uniform(-3, 3, 256)
17+
z = (1 - x/2 + x**5 + y**3) * np.exp(-x**2 - y**2)
2218

2319
# plot:
2420
fig, ax = plt.subplots()
25-
ax.grid(False)
2621

2722
ax.triplot(x, y)
2823

0 commit comments

Comments
 (0)