diff --git a/doc/sphinxext/gallery_order.py b/doc/sphinxext/gallery_order.py index 8705d473c81e..589fed453f06 100644 --- a/doc/sphinxext/gallery_order.py +++ b/doc/sphinxext/gallery_order.py @@ -68,12 +68,13 @@ def __call__(self, item): # **Plot Types # Basic - "plot", "scatter_plot", "bar", "stem", "step", "pie", "fill_between", + "plot", "scatter_plot", "bar", "stem", "step", "fill_between", # Arrays - "imshow", "pcolormesh", "contour", "contourf", "quiver", "streamplot", + "imshow", "pcolormesh", "contour", "contourf", + "barbs", "quiver", "streamplot", # Stats "hist_plot", "boxplot_plot", "errorbar_plot", "violin", - "barbs", "eventplot", "hist2d", "hexbin", + "eventplot", "hist2d", "hexbin", "pie", # Unstructured "tricontour", "tricontourf", "tripcolor", "triplot", ] diff --git a/plot_types/arrays/barbs.py b/plot_types/arrays/barbs.py new file mode 100644 index 000000000000..a54424a58b46 --- /dev/null +++ b/plot_types/arrays/barbs.py @@ -0,0 +1,33 @@ +""" +================ +barbs(X, Y U, V) +================ + +See `~matplotlib.axes.Axes.barbs`. +""" +import matplotlib.pyplot as plt +import numpy as np + +plt.style.use('_mpl-gallery-nogrid') + +# make data: +X, Y = np.meshgrid([1, 2, 3, 4], [1, 2, 3, 4]) +angle = np.pi / 180 * np.array([[15., 30, 35, 45], + [25., 40, 55, 60], + [35., 50, 65, 75], + [45., 60, 75, 90]]) +amplitude = np.array([[5, 10, 25, 50], + [10, 15, 30, 60], + [15, 26, 50, 70], + [20, 45, 80, 100]]) +U = amplitude * np.sin(angle) +V = amplitude * np.cos(angle) + +# plot: +fig, ax = plt.subplots() + +ax.barbs(X, Y, U, V, barbcolor="C0", flagcolor="C0", length=7, linewidth=1.5) + +ax.set(xlim=(0, 4.5), ylim=(0, 4.5)) + +plt.show() diff --git a/plot_types/arrays/imshow.py b/plot_types/arrays/imshow.py index beca827cdc80..be647d1f2924 100644 --- a/plot_types/arrays/imshow.py +++ b/plot_types/arrays/imshow.py @@ -12,9 +12,8 @@ plt.style.use('_mpl-gallery-nogrid') # make data -X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) +X, Y = np.meshgrid(np.linspace(-3, 3, 16), np.linspace(-3, 3, 16)) Z = (1 - X/2 + X**5 + Y**3) * np.exp(-X**2 - Y**2) -Z = Z[::16, ::16] # plot fig, ax = plt.subplots() diff --git a/plot_types/arrays/pcolormesh.py b/plot_types/arrays/pcolormesh.py index dad94dd2ae5d..b490dcb99d3f 100644 --- a/plot_types/arrays/pcolormesh.py +++ b/plot_types/arrays/pcolormesh.py @@ -12,18 +12,11 @@ plt.style.use('_mpl-gallery-nogrid') -# make full-res data -X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) +# make data with uneven sampling in x +x = [-3, -2, -1.6, -1.2, -.8, -.5, -.2, .1, .3, .5, .8, 1.1, 1.5, 1.9, 2.3, 3] +X, Y = np.meshgrid(x, np.linspace(-3, 3, 128)) 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 -dx = np.floor(dx / sum(dx) * 255) -xint = np.cumsum(dx).astype('int') -X = X[0, xint] -Y = Y[::8, 0] -Z = Z[::8, :][:, xint] - # plot fig, ax = plt.subplots() diff --git a/plot_types/stats/barbs.py b/plot_types/stats/barbs.py deleted file mode 100644 index 7b632139662d..000000000000 --- a/plot_types/stats/barbs.py +++ /dev/null @@ -1,28 +0,0 @@ -""" -=========== -barbs(U, V) -=========== - -See `~matplotlib.axes.Axes.barbs`. -""" -import matplotlib.pyplot as plt -import numpy as np - -plt.style.use('_mpl-gallery') - -# make data: -np.random.seed(1) -X = [[2, 4, 6]] -Y = [[1.5, 3, 2]] -U = np.zeros_like(X) -V = -np.ones_like(X) * np.linspace(50, 100, 3) - -# plot: -fig, ax = plt.subplots() - -ax.barbs(X, Y, U, V, barbcolor="C0", flagcolor="C0", length=10, linewidth=1.5) - -ax.set(xlim=(0, 8), xticks=np.arange(1, 8), - ylim=(0, 8), yticks=np.arange(1, 8)) - -plt.show() diff --git a/plot_types/basic/pie.py b/plot_types/stats/pie.py similarity index 100% rename from plot_types/basic/pie.py rename to plot_types/stats/pie.py