From 6b149ca221a5530ea5e096d043d0bf49ee763f0d Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Mon, 20 Sep 2021 00:03:52 +0200 Subject: [PATCH 1/5] Consider new plots for gallery ordering --- doc/sphinxext/gallery_order.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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] From dad3d7707145f349f10ace316cf6970a72da8fec Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Mon, 20 Sep 2021 00:18:15 +0200 Subject: [PATCH 2/5] Use a second style for plot types gallery entries without grid This declutters the code. --- .../stylelib/_mpl-gallery-nogrid.mplstyle | 19 +++++++++++++++++++ ...gallery.mplstyle => _mpl-gallery.mplstyle} | 2 +- plot_types/arrays/contour.py | 3 +-- plot_types/arrays/contourf.py | 2 +- plot_types/arrays/imshow.py | 3 +-- plot_types/arrays/pcolormesh.py | 3 +-- plot_types/arrays/quiver.py | 2 +- plot_types/arrays/streamplot.py | 3 +-- plot_types/basic/bar.py | 2 +- plot_types/basic/pie.py | 2 +- plot_types/basic/plot.py | 2 +- plot_types/basic/scatter_plot.py | 2 +- plot_types/basic/stem.py | 2 +- plot_types/basic/step.py | 2 +- plot_types/stats/barbs.py | 2 +- plot_types/stats/boxplot_plot.py | 2 +- plot_types/stats/errorbar_plot.py | 2 +- plot_types/stats/eventplot.py | 2 +- plot_types/stats/hexbin.py | 2 +- plot_types/stats/hist2d.py | 2 +- plot_types/stats/hist_plot.py | 2 +- plot_types/stats/violin.py | 2 +- plot_types/unstructured/tricontour.py | 3 +-- plot_types/unstructured/tricontourf.py | 3 +-- plot_types/unstructured/tripcolor.py | 2 +- plot_types/unstructured/triplot.py | 3 +-- 26 files changed, 44 insertions(+), 32 deletions(-) create mode 100644 lib/matplotlib/mpl-data/stylelib/_mpl-gallery-nogrid.mplstyle rename lib/matplotlib/mpl-data/stylelib/{mpl_plot_gallery.mplstyle => _mpl-gallery.mplstyle} (84%) 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 84% rename from lib/matplotlib/mpl-data/stylelib/mpl_plot_gallery.mplstyle rename to lib/matplotlib/mpl-data/stylelib/_mpl-gallery.mplstyle index 31aa18ad134e..1919191fa68b 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 private. 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..4aac5a28f8de 100644 --- a/plot_types/arrays/imshow.py +++ b/plot_types/arrays/imshow.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-nogrid') # make data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) @@ -18,7 +18,6 @@ # 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..a56b9ceb1679 100644 --- a/plot_types/arrays/pcolormesh.py +++ b/plot_types/arrays/pcolormesh.py @@ -10,7 +10,7 @@ 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)) @@ -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..8047ddd5375a 100644 --- a/plot_types/arrays/streamplot.py +++ b/plot_types/arrays/streamplot.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 a stream function: X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) @@ -19,7 +19,6 @@ # plot: fig, ax = plt.subplots() -ax.grid(False) # plot stream plot ax.streamplot(X[1:, 1:], Y[1:, 1:], U, V) 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..98e9e5b7597c 100644 --- a/plot_types/unstructured/tricontour.py +++ b/plot_types/unstructured/tricontour.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 structured data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) @@ -25,7 +25,6 @@ # 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..a32b9c491e64 100644 --- a/plot_types/unstructured/tricontourf.py +++ b/plot_types/unstructured/tricontourf.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 structured data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) @@ -25,7 +25,6 @@ # 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..115ec1a69707 100644 --- a/plot_types/unstructured/tripcolor.py +++ b/plot_types/unstructured/tripcolor.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 structured data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) diff --git a/plot_types/unstructured/triplot.py b/plot_types/unstructured/triplot.py index d92e77de0695..c8f3bc172ce7 100644 --- a/plot_types/unstructured/triplot.py +++ b/plot_types/unstructured/triplot.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 structured data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) @@ -22,7 +22,6 @@ # plot: fig, ax = plt.subplots() -ax.grid(False) ax.triplot(x, y) From cb41936915edd738da9167c7a0a057b1b1c57a50 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Mon, 20 Sep 2021 00:28:51 +0200 Subject: [PATCH 3/5] Minor style fixes in plot types --- plot_types/arrays/imshow.py | 2 +- plot_types/arrays/pcolormesh.py | 2 +- plot_types/arrays/streamplot.py | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/plot_types/arrays/imshow.py b/plot_types/arrays/imshow.py index 4aac5a28f8de..beca827cdc80 100644 --- a/plot_types/arrays/imshow.py +++ b/plot_types/arrays/imshow.py @@ -13,7 +13,7 @@ # 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 diff --git a/plot_types/arrays/pcolormesh.py b/plot_types/arrays/pcolormesh.py index a56b9ceb1679..dad94dd2ae5d 100644 --- a/plot_types/arrays/pcolormesh.py +++ b/plot_types/arrays/pcolormesh.py @@ -14,7 +14,7 @@ # 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 diff --git a/plot_types/arrays/streamplot.py b/plot_types/arrays/streamplot.py index 8047ddd5375a..3f1e2ef4e1cc 100644 --- a/plot_types/arrays/streamplot.py +++ b/plot_types/arrays/streamplot.py @@ -12,7 +12,7 @@ # 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) @@ -20,7 +20,6 @@ # plot: fig, ax = plt.subplots() -# plot stream plot ax.streamplot(X[1:, 1:], Y[1:, 1:], U, V) plt.show() From 9dd1441ed36dc8a0273925052960dd5c6c49baa7 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Mon, 20 Sep 2021 00:47:12 +0200 Subject: [PATCH 4/5] Simplify unstructured data generation There is no need to generate a regular grid and statistically choose points from that. Instead, we can immediately choose random points. --- plot_types/unstructured/tricontour.py | 16 +++++----------- plot_types/unstructured/tricontourf.py | 16 +++++----------- plot_types/unstructured/tripcolor.py | 14 ++++---------- plot_types/unstructured/triplot.py | 12 ++++-------- 4 files changed, 18 insertions(+), 40 deletions(-) diff --git a/plot_types/unstructured/tricontour.py b/plot_types/unstructured/tricontour.py index 98e9e5b7597c..83b0a212fd83 100644 --- a/plot_types/unstructured/tricontour.py +++ b/plot_types/unstructured/tricontour.py @@ -10,18 +10,12 @@ 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() diff --git a/plot_types/unstructured/tricontourf.py b/plot_types/unstructured/tricontourf.py index a32b9c491e64..da909c02f0b2 100644 --- a/plot_types/unstructured/tricontourf.py +++ b/plot_types/unstructured/tricontourf.py @@ -10,18 +10,12 @@ 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() diff --git a/plot_types/unstructured/tripcolor.py b/plot_types/unstructured/tripcolor.py index 115ec1a69707..e2619a68444e 100644 --- a/plot_types/unstructured/tripcolor.py +++ b/plot_types/unstructured/tripcolor.py @@ -10,17 +10,11 @@ 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 c8f3bc172ce7..78cf8e32a318 100644 --- a/plot_types/unstructured/triplot.py +++ b/plot_types/unstructured/triplot.py @@ -10,15 +10,11 @@ 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() From e86f764672a18349aab006622e020049495c855c Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Thu, 23 Sep 2021 08:51:21 +0200 Subject: [PATCH 5/5] Update lib/matplotlib/mpl-data/stylelib/_mpl-gallery.mplstyle Co-authored-by: hannah --- lib/matplotlib/mpl-data/stylelib/_mpl-gallery.mplstyle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/mpl-data/stylelib/_mpl-gallery.mplstyle b/lib/matplotlib/mpl-data/stylelib/_mpl-gallery.mplstyle index 1919191fa68b..e5916c866902 100644 --- a/lib/matplotlib/mpl-data/stylelib/_mpl-gallery.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/_mpl-gallery.mplstyle @@ -1,4 +1,4 @@ -# This style is used for the plot_types gallery. It is considered private. +# This style is used for the plot_types gallery. It is considered part of the private API. axes.grid: True axes.axisbelow: True