Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 062b5b2

Browse files
authored
Merge pull request #21221 from timhoffm/plot-t
Updates to plot types
2 parents 1a040b2 + ce8342f commit 062b5b2

File tree

6 files changed

+41
-43
lines changed

6 files changed

+41
-43
lines changed

doc/sphinxext/gallery_order.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,13 @@ def __call__(self, item):
6868

6969
# **Plot Types
7070
# Basic
71-
"plot", "scatter_plot", "bar", "stem", "step", "pie", "fill_between",
71+
"plot", "scatter_plot", "bar", "stem", "step", "fill_between",
7272
# Arrays
73-
"imshow", "pcolormesh", "contour", "contourf", "quiver", "streamplot",
73+
"imshow", "pcolormesh", "contour", "contourf",
74+
"barbs", "quiver", "streamplot",
7475
# Stats
7576
"hist_plot", "boxplot_plot", "errorbar_plot", "violin",
76-
"barbs", "eventplot", "hist2d", "hexbin",
77+
"eventplot", "hist2d", "hexbin", "pie",
7778
# Unstructured
7879
"tricontour", "tricontourf", "tripcolor", "triplot",
7980
]

plot_types/arrays/barbs.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""
2+
================
3+
barbs(X, Y U, V)
4+
================
5+
6+
See `~matplotlib.axes.Axes.barbs`.
7+
"""
8+
import matplotlib.pyplot as plt
9+
import numpy as np
10+
11+
plt.style.use('_mpl-gallery-nogrid')
12+
13+
# make data:
14+
X, Y = np.meshgrid([1, 2, 3, 4], [1, 2, 3, 4])
15+
angle = np.pi / 180 * np.array([[15., 30, 35, 45],
16+
[25., 40, 55, 60],
17+
[35., 50, 65, 75],
18+
[45., 60, 75, 90]])
19+
amplitude = np.array([[5, 10, 25, 50],
20+
[10, 15, 30, 60],
21+
[15, 26, 50, 70],
22+
[20, 45, 80, 100]])
23+
U = amplitude * np.sin(angle)
24+
V = amplitude * np.cos(angle)
25+
26+
# plot:
27+
fig, ax = plt.subplots()
28+
29+
ax.barbs(X, Y, U, V, barbcolor="C0", flagcolor="C0", length=7, linewidth=1.5)
30+
31+
ax.set(xlim=(0, 4.5), ylim=(0, 4.5))
32+
33+
plt.show()

plot_types/arrays/imshow.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
plt.style.use('_mpl-gallery-nogrid')
1313

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

1918
# plot
2019
fig, ax = plt.subplots()

plot_types/arrays/pcolormesh.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,11 @@
1212

1313
plt.style.use('_mpl-gallery-nogrid')
1414

15-
# make full-res data
16-
X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256))
15+
# make data with uneven sampling in x
16+
x = [-3, -2, -1.6, -1.2, -.8, -.5, -.2, .1, .3, .5, .8, 1.1, 1.5, 1.9, 2.3, 3]
17+
X, Y = np.meshgrid(x, np.linspace(-3, 3, 128))
1718
Z = (1 - X/2 + X**5 + Y**3) * np.exp(-X**2 - Y**2)
1819

19-
# sample unevenly in x:
20-
dx = np.sqrt((np.arange(16) - 8)**2) + 6
21-
dx = np.floor(dx / sum(dx) * 255)
22-
xint = np.cumsum(dx).astype('int')
23-
X = X[0, xint]
24-
Y = Y[::8, 0]
25-
Z = Z[::8, :][:, xint]
26-
2720
# plot
2821
fig, ax = plt.subplots()
2922

plot_types/stats/barbs.py

Lines changed: 0 additions & 28 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)