Skip to content

Updates to plot types #21221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions doc/sphinxext/gallery_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down
33 changes: 33 additions & 0 deletions plot_types/arrays/barbs.py
Original file line number Diff line number Diff line change
@@ -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()
3 changes: 1 addition & 2 deletions plot_types/arrays/imshow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
13 changes: 3 additions & 10 deletions plot_types/arrays/pcolormesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
28 changes: 0 additions & 28 deletions plot_types/stats/barbs.py

This file was deleted.

File renamed without changes.