Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Backport PR #21136 on branch v3.5.x (More (minor) plot types gallery fixes.)#21160

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall 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
4 changes: 2 additions & 2 deletionsdoc/sphinxext/gallery_order.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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]

Expand Down
19 changes: 19 additions & 0 deletionslib/matplotlib/mpl-data/stylelib/_mpl-gallery-nogrid.mplstyle
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -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'])
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
#fromtheMatplotlib cheatsheet as used in our gallery:
#This style is used fortheplot_types gallery. It is considered part of the private API.

axes.grid: True
axes.axisbelow: True
Expand Down
3 changes: 1 addition & 2 deletionsplot_types/arrays/contour.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@
importmatplotlib.pyplotasplt
importnumpyasnp

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))
Expand All@@ -17,7 +17,6 @@

# plot
fig,ax=plt.subplots()
ax.grid(False)

ax.contour(X,Y,Z,levels=levels)

Expand Down
2 changes: 1 addition & 1 deletionplot_types/arrays/contourf.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@
importmatplotlib.pyplotasplt
importnumpyasnp

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))
Expand Down
5 changes: 2 additions & 3 deletionsplot_types/arrays/imshow.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)

Expand Down
5 changes: 2 additions & 3 deletionsplot_types/arrays/pcolormesh.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Expand All@@ -26,7 +26,6 @@

# plot
fig, ax = plt.subplots()
ax.grid(False)

ax.pcolormesh(X, Y, Z, vmin=-0.5, vmax=1.0)

Expand Down
2 changes: 1 addition & 1 deletionplot_types/arrays/quiver.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@
importmatplotlib.pyplotasplt
importnumpyasnp

plt.style.use('mpl_plot_gallery')
plt.style.use('_mpl-gallery')

# make data
phi=np.linspace(0,2*np.pi,8)
Expand Down
6 changes: 2 additions & 4 deletionsplot_types/arrays/streamplot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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()
2 changes: 1 addition & 1 deletionplot_types/basic/bar.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down
2 changes: 1 addition & 1 deletionplot_types/basic/pie.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@
importmatplotlib.pyplotasplt
importnumpyasnp

plt.style.use('mpl_plot_gallery')
plt.style.use('_mpl-gallery-nogrid')


# make data
Expand Down
2 changes: 1 addition & 1 deletionplot_types/basic/plot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@
importmatplotlib.pyplotasplt
importnumpyasnp

plt.style.use('mpl_plot_gallery')
plt.style.use('_mpl-gallery')

# make data
x=np.linspace(0,10,100)
Expand Down
2 changes: 1 addition & 1 deletionplot_types/basic/scatter_plot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down
2 changes: 1 addition & 1 deletionplot_types/basic/stem.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down
2 changes: 1 addition & 1 deletionplot_types/basic/step.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@
importmatplotlib.pyplotasplt
importnumpyasnp

plt.style.use('mpl_plot_gallery')
plt.style.use('_mpl-gallery')

# make data
np.random.seed(3)
Expand Down
2 changes: 1 addition & 1 deletionplot_types/stats/barbs.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@
importmatplotlib.pyplotasplt
importnumpyasnp

plt.style.use('mpl_plot_gallery')
plt.style.use('_mpl-gallery')

# make data:
np.random.seed(1)
Expand Down
2 changes: 1 addition & 1 deletionplot_types/stats/boxplot_plot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@
importmatplotlib.pyplotasplt
importnumpyasnp

plt.style.use('mpl_plot_gallery')
plt.style.use('_mpl-gallery')

# make data:
np.random.seed(10)
Expand Down
2 changes: 1 addition & 1 deletionplot_types/stats/errorbar_plot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down
2 changes: 1 addition & 1 deletionplot_types/stats/eventplot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down
2 changes: 1 addition & 1 deletionplot_types/stats/hexbin.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down
2 changes: 1 addition & 1 deletionplot_types/stats/hist2d.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down
2 changes: 1 addition & 1 deletionplot_types/stats/hist_plot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down
2 changes: 1 addition & 1 deletionplot_types/stats/violin.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down
19 changes: 6 additions & 13 deletionsplot_types/unstructured/tricontour.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down
19 changes: 6 additions & 13 deletionsplot_types/unstructured/tricontourf.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down
16 changes: 5 additions & 11 deletionsplot_types/unstructured/tripcolor.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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()
Expand Down
15 changes: 5 additions & 10 deletionsplot_types/unstructured/triplot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp