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

Commit83b3fef

Browse files
authored
Merge pull request#26253 from LemonBoy/inf-surf
Filter out inf values in plot_surface
2 parents427392e +ba7af99 commit83b3fef

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

‎lib/mpl_toolkits/mplot3d/axes3d.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,18 +1708,18 @@ def plot_surface(self, X, Y, Z, *, norm=None, vmin=None,
17081708
iffcolorsisnotNone:
17091709
colset.append(fcolors[rs][cs])
17101710

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

17181718
# Depending on fcolors, colset is either an empty list or has as
17191719
# many elements as polys. In the former case new_colset results in
17201720
# a list with None entries, that is discarded later.
17211721
forp,colinitertools.zip_longest(polys,colset):
1722-
new_poly=np.array(p)[~np.isnan(p).any(axis=1)]
1722+
new_poly=np.array(p)[np.isfinite(p).all(axis=1)]
17231723
iflen(new_poly):
17241724
new_polys.append(new_poly)
17251725
new_colset.append(col)
87.3 KB
Loading

‎lib/mpl_toolkits/mplot3d/tests/test_axes3d.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,3 +2244,16 @@ def test_scatter_masked_color():
22442244
# Assert sizes' equality
22452245
assertlen(path3d.get_offsets())==\
22462246
len(super(type(path3d),path3d).get_facecolors())
2247+
2248+
2249+
@mpl3d_image_comparison(['surface3d_zsort_inf.png'],style='mpl20')
2250+
deftest_surface3d_zsort_inf():
2251+
fig=plt.figure()
2252+
ax=fig.add_subplot(projection='3d')
2253+
2254+
x,y=np.mgrid[-2:2:0.1,-2:2:0.1]
2255+
z=np.sin(x)**2+np.cos(y)**2
2256+
z[x.shape[0]//2:,x.shape[1]//2:]=np.inf
2257+
2258+
ax.plot_surface(x,y,z,cmap='jet')
2259+
ax.view_init(elev=45,azim=145)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp