diff --git a/doc/sphinxext/gallery_order.py b/doc/sphinxext/gallery_order.py index 9c53fff9f131..8705d473c81e 100644 --- a/doc/sphinxext/gallery_order.py +++ b/doc/sphinxext/gallery_order.py @@ -70,12 +70,12 @@ def __call__(self, item): # Basic "plot", "scatter_plot", "bar", "stem", "step", "pie", "fill_between", # Arrays - "imshow", "pcolormesh", "contourf", "quiver", "streamplot", + "imshow", "pcolormesh", "contour", "contourf", "quiver", "streamplot", # Stats "hist_plot", "boxplot_plot", "errorbar_plot", "violin", "barbs", "eventplot", "hist2d", "hexbin", # Unstructured - "tricontour", "tripcolor", "triplot", + "tricontour", "tricontourf", "tripcolor", "triplot", ] explicit_subsection_order = [item + ".py" for item in list_all] diff --git a/lib/matplotlib/mpl-data/stylelib/_mpl-gallery-nogrid.mplstyle b/lib/matplotlib/mpl-data/stylelib/_mpl-gallery-nogrid.mplstyle new file mode 100644 index 000000000000..55ed1ab013cb --- /dev/null +++ b/lib/matplotlib/mpl-data/stylelib/_mpl-gallery-nogrid.mplstyle @@ -0,0 +1,19 @@ +# This style is used for the plot_types gallery. It is considered private. + +axes.grid: False +axes.axisbelow: True + +figure.figsize: 2, 2 +# make it so the axes labels don't show up. Obviously +# not good style for any quantitative analysis: +figure.subplot.left: 0.01 +figure.subplot.right: 0.99 +figure.subplot.bottom: 0.01 +figure.subplot.top: 0.99 + +xtick.major.size: 0.0 +ytick.major.size: 0.0 + +# colors: +image.cmap : Blues +# axes.prop_cycle: cycler('color', ['FF7F0E', '1F77B4', '2CA02C']) diff --git a/lib/matplotlib/mpl-data/stylelib/mpl_plot_gallery.mplstyle b/lib/matplotlib/mpl-data/stylelib/_mpl-gallery.mplstyle similarity index 82% rename from lib/matplotlib/mpl-data/stylelib/mpl_plot_gallery.mplstyle rename to lib/matplotlib/mpl-data/stylelib/_mpl-gallery.mplstyle index 31aa18ad134e..e5916c866902 100644 --- a/lib/matplotlib/mpl-data/stylelib/mpl_plot_gallery.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/_mpl-gallery.mplstyle @@ -1,4 +1,4 @@ -# from the Matplotlib cheatsheet as used in our gallery: +# This style is used for the plot_types gallery. It is considered part of the private API. axes.grid: True axes.axisbelow: True diff --git a/plot_types/arrays/contour.py b/plot_types/arrays/contour.py index 77a80c3e2027..fe79c18d2b58 100644 --- a/plot_types/arrays/contour.py +++ b/plot_types/arrays/contour.py @@ -8,7 +8,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery-nogrid') # make data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) @@ -17,7 +17,6 @@ # plot fig, ax = plt.subplots() -ax.grid(False) ax.contour(X, Y, Z, levels=levels) diff --git a/plot_types/arrays/contourf.py b/plot_types/arrays/contourf.py index eda5222e4b3a..bde2f984fc0f 100644 --- a/plot_types/arrays/contourf.py +++ b/plot_types/arrays/contourf.py @@ -8,7 +8,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery-nogrid') # make data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) diff --git a/plot_types/arrays/imshow.py b/plot_types/arrays/imshow.py index 53b50f667a37..beca827cdc80 100644 --- a/plot_types/arrays/imshow.py +++ b/plot_types/arrays/imshow.py @@ -9,16 +9,15 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery-nogrid') # make data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) -Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2) +Z = (1 - X/2 + X**5 + Y**3) * np.exp(-X**2 - Y**2) Z = Z[::16, ::16] # plot fig, ax = plt.subplots() -ax.grid(False) ax.imshow(Z) diff --git a/plot_types/arrays/pcolormesh.py b/plot_types/arrays/pcolormesh.py index 30d166ff0d71..dad94dd2ae5d 100644 --- a/plot_types/arrays/pcolormesh.py +++ b/plot_types/arrays/pcolormesh.py @@ -10,11 +10,11 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery-nogrid') # make full-res data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) -Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2) +Z = (1 - X/2 + X**5 + Y**3) * np.exp(-X**2 - Y**2) # sample unevenly in x: dx = np.sqrt((np.arange(16) - 8)**2) + 6 @@ -26,7 +26,6 @@ # plot fig, ax = plt.subplots() -ax.grid(False) ax.pcolormesh(X, Y, Z, vmin=-0.5, vmax=1.0) diff --git a/plot_types/arrays/quiver.py b/plot_types/arrays/quiver.py index f1a618850f90..8402b98f0f4f 100644 --- a/plot_types/arrays/quiver.py +++ b/plot_types/arrays/quiver.py @@ -8,7 +8,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery') # make data phi = np.linspace(0, 2 * np.pi, 8) diff --git a/plot_types/arrays/streamplot.py b/plot_types/arrays/streamplot.py index d50d9cea6580..3f1e2ef4e1cc 100644 --- a/plot_types/arrays/streamplot.py +++ b/plot_types/arrays/streamplot.py @@ -8,20 +8,18 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery-nogrid') # make a stream function: X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) -Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2) +Z = (1 - X/2 + X**5 + Y**3) * np.exp(-X**2 - Y**2) # make U and V out of the streamfunction: V = np.diff(Z[1:, :], axis=1) U = -np.diff(Z[:, 1:], axis=0) # plot: fig, ax = plt.subplots() -ax.grid(False) -# plot stream plot ax.streamplot(X[1:, 1:], Y[1:, 1:], U, V) plt.show() diff --git a/plot_types/basic/bar.py b/plot_types/basic/bar.py index 6c933b018935..d192a90e8525 100644 --- a/plot_types/basic/bar.py +++ b/plot_types/basic/bar.py @@ -7,7 +7,7 @@ """ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery') # make data: np.random.seed(3) diff --git a/plot_types/basic/pie.py b/plot_types/basic/pie.py index b078a8f5e6ab..80484a0eb932 100644 --- a/plot_types/basic/pie.py +++ b/plot_types/basic/pie.py @@ -8,7 +8,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery-nogrid') # make data diff --git a/plot_types/basic/plot.py b/plot_types/basic/plot.py index ac93ecf71b56..3808137e52fd 100644 --- a/plot_types/basic/plot.py +++ b/plot_types/basic/plot.py @@ -9,7 +9,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery') # make data x = np.linspace(0, 10, 100) diff --git a/plot_types/basic/scatter_plot.py b/plot_types/basic/scatter_plot.py index 68f06744150c..792016c0e79c 100644 --- a/plot_types/basic/scatter_plot.py +++ b/plot_types/basic/scatter_plot.py @@ -8,7 +8,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery') # make the data np.random.seed(3) diff --git a/plot_types/basic/stem.py b/plot_types/basic/stem.py index 22bcdde73861..8e7b29283c01 100644 --- a/plot_types/basic/stem.py +++ b/plot_types/basic/stem.py @@ -8,7 +8,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery') # make data np.random.seed(3) diff --git a/plot_types/basic/step.py b/plot_types/basic/step.py index 4ec9a96544ac..558550a5c498 100644 --- a/plot_types/basic/step.py +++ b/plot_types/basic/step.py @@ -8,7 +8,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery') # make data np.random.seed(3) diff --git a/plot_types/stats/barbs.py b/plot_types/stats/barbs.py index 727b41f19244..7b632139662d 100644 --- a/plot_types/stats/barbs.py +++ b/plot_types/stats/barbs.py @@ -8,7 +8,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery') # make data: np.random.seed(1) diff --git a/plot_types/stats/boxplot_plot.py b/plot_types/stats/boxplot_plot.py index fad2d69a6f5d..cdad3c52320f 100644 --- a/plot_types/stats/boxplot_plot.py +++ b/plot_types/stats/boxplot_plot.py @@ -8,7 +8,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery') # make data: np.random.seed(10) diff --git a/plot_types/stats/errorbar_plot.py b/plot_types/stats/errorbar_plot.py index 95b38c383ca0..0e226e11b315 100644 --- a/plot_types/stats/errorbar_plot.py +++ b/plot_types/stats/errorbar_plot.py @@ -8,7 +8,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery') # make data: np.random.seed(1) diff --git a/plot_types/stats/eventplot.py b/plot_types/stats/eventplot.py index 0552d83e599c..da8c33c28425 100644 --- a/plot_types/stats/eventplot.py +++ b/plot_types/stats/eventplot.py @@ -8,7 +8,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery') # make data: np.random.seed(1) diff --git a/plot_types/stats/hexbin.py b/plot_types/stats/hexbin.py index 87a3594ab009..91e771308afd 100644 --- a/plot_types/stats/hexbin.py +++ b/plot_types/stats/hexbin.py @@ -8,7 +8,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery-nogrid') # make data: correlated + noise np.random.seed(1) diff --git a/plot_types/stats/hist2d.py b/plot_types/stats/hist2d.py index 90f60eda4a34..3e43f7ee8ace 100644 --- a/plot_types/stats/hist2d.py +++ b/plot_types/stats/hist2d.py @@ -8,7 +8,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery-nogrid') # make data: correlated + noise np.random.seed(1) diff --git a/plot_types/stats/hist_plot.py b/plot_types/stats/hist_plot.py index ccd13cc829d8..6c86a0aca216 100644 --- a/plot_types/stats/hist_plot.py +++ b/plot_types/stats/hist_plot.py @@ -8,7 +8,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery') # make data np.random.seed(1) diff --git a/plot_types/stats/violin.py b/plot_types/stats/violin.py index 40b8f19341ab..c8a987a690dd 100644 --- a/plot_types/stats/violin.py +++ b/plot_types/stats/violin.py @@ -8,7 +8,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery') # make data: np.random.seed(10) diff --git a/plot_types/unstructured/tricontour.py b/plot_types/unstructured/tricontour.py index 110d13bafca4..83b0a212fd83 100644 --- a/plot_types/unstructured/tricontour.py +++ b/plot_types/unstructured/tricontour.py @@ -8,24 +8,17 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery-nogrid') -# make structured data -X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) -Z = (1 - X/2 + X**5 + Y**3) * np.exp(-X**2 - Y**2) -levels = np.linspace(Z.min(), Z.max(), 7) - -# sample it to make unstructured x, y, z +# make data: np.random.seed(1) -ysamp = np.random.randint(0, 256, size=250) -xsamp = np.random.randint(0, 256, size=250) -y = Y[:, 0][ysamp] -x = X[0, :][xsamp] -z = Z[ysamp, xsamp] +x = np.random.uniform(-3, 3, 256) +y = np.random.uniform(-3, 3, 256) +z = (1 - x/2 + x**5 + y**3) * np.exp(-x**2 - y**2) +levels = np.linspace(z.min(), z.max(), 7) # plot: fig, ax = plt.subplots() -ax.grid(False) ax.plot(x, y, 'o', markersize=2, color='lightgrey') ax.tricontour(x, y, z, levels=levels) diff --git a/plot_types/unstructured/tricontourf.py b/plot_types/unstructured/tricontourf.py index a9b76b13db94..da909c02f0b2 100644 --- a/plot_types/unstructured/tricontourf.py +++ b/plot_types/unstructured/tricontourf.py @@ -8,24 +8,17 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery-nogrid') -# make structured data -X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) -Z = (1 - X/2 + X**5 + Y**3) * np.exp(-X**2 - Y**2) -levels = np.linspace(np.min(Z), np.max(Z), 7) - -# sample it to make unstructured x, y, z +# make data: np.random.seed(1) -ysamp = np.random.randint(0, 256, size=250) -xsamp = np.random.randint(0, 256, size=250) -y = Y[:, 0][ysamp] -x = X[0, :][xsamp] -z = Z[ysamp, xsamp] +x = np.random.uniform(-3, 3, 256) +y = np.random.uniform(-3, 3, 256) +z = (1 - x/2 + x**5 + y**3) * np.exp(-x**2 - y**2) +levels = np.linspace(z.min(), z.max(), 7) # plot: fig, ax = plt.subplots() -ax.grid(False) ax.plot(x, y, 'o', markersize=2, color='grey') ax.tricontourf(x, y, z, levels=levels) diff --git a/plot_types/unstructured/tripcolor.py b/plot_types/unstructured/tripcolor.py index cc694e1d8433..e2619a68444e 100644 --- a/plot_types/unstructured/tripcolor.py +++ b/plot_types/unstructured/tripcolor.py @@ -8,19 +8,13 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery-nogrid') -# make structured data -X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) -Z = (1 - X/2 + X**5 + Y**3) * np.exp(-X**2 - Y**2) - -# sample it to make unstructured x, y, z +# make data: np.random.seed(1) -ysamp = np.random.randint(0, 256, size=250) -xsamp = np.random.randint(0, 256, size=250) -y = Y[:, 0][ysamp] -x = X[0, :][xsamp] -z = Z[ysamp, xsamp] +x = np.random.uniform(-3, 3, 256) +y = np.random.uniform(-3, 3, 256) +z = (1 - x/2 + x**5 + y**3) * np.exp(-x**2 - y**2) # plot: fig, ax = plt.subplots() diff --git a/plot_types/unstructured/triplot.py b/plot_types/unstructured/triplot.py index d92e77de0695..78cf8e32a318 100644 --- a/plot_types/unstructured/triplot.py +++ b/plot_types/unstructured/triplot.py @@ -8,21 +8,16 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('mpl_plot_gallery') +plt.style.use('_mpl-gallery-nogrid') -# make structured data -X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) - -# sample it to make x, y, z +# make data: np.random.seed(1) -ysamp = np.random.randint(0, 256, size=250) -xsamp = np.random.randint(0, 256, size=250) -y = Y[:, 0][ysamp] -x = X[0, :][xsamp] +x = np.random.uniform(-3, 3, 256) +y = np.random.uniform(-3, 3, 256) +z = (1 - x/2 + x**5 + y**3) * np.exp(-x**2 - y**2) # plot: fig, ax = plt.subplots() -ax.grid(False) ax.triplot(x, y)