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

Filter out inf values in plot_surface#26253

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
tacaswell merged 4 commits intomatplotlib:mainfromLemonBoy:inf-surf
Aug 3, 2023
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
10 changes: 5 additions & 5 deletionslib/mpl_toolkits/mplot3d/axes3d.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1702,18 +1702,18 @@ def plot_surface(self, X, Y, Z, *, norm=None, vmin=None,
if fcolors is not None:
colset.append(fcolors[rs][cs])

# In cases where there areNaNsin the data (possiblyfrom masked
# arrays), artifacts can be introduced. Here check whetherNaNs exist
# and removethe entries if so
if not isinstance(polys, np.ndarray) or np.isnan(polys).any():
# In cases where there arenon-finite valuesin the data (possiblyNaNs from
#maskedarrays), artifacts can be introduced. Here check whethersuch values
#are presentand removethem.
if not isinstance(polys, np.ndarray) ornotnp.isfinite(polys).all():
new_polys = []
new_colset = []

# Depending on fcolors, colset is either an empty list or has as
# many elements as polys. In the former case new_colset results in
# a list with None entries, that is discarded later.
for p, col in itertools.zip_longest(polys, colset):
new_poly = np.array(p)[~np.isnan(p).any(axis=1)]
new_poly = np.array(p)[np.isfinite(p).all(axis=1)]
if len(new_poly):
new_polys.append(new_poly)
new_colset.append(col)
Expand Down
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletionslib/mpl_toolkits/mplot3d/tests/test_axes3d.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2232,3 +2232,16 @@ def test_scatter_masked_color():
# Assert sizes' equality
assert len(path3d.get_offsets()) ==\
len(super(type(path3d), path3d).get_facecolors())


@mpl3d_image_comparison(['surface3d_zsort_inf.png'], style='mpl20')
def test_surface3d_zsort_inf():
fig = plt.figure()
ax = fig.add_subplot(projection='3d')

x, y = np.mgrid[-2:2:0.1, -2:2:0.1]
z = np.sin(x)**2 + np.cos(y)**2
z[x.shape[0] // 2:, x.shape[1] // 2:] = np.inf

ax.plot_surface(x, y, z, cmap='jet')
ax.view_init(elev=45, azim=145)

[8]ページ先頭

©2009-2025 Movatter.jp