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

Commit40544ec

Browse files
authored
Merge pull request#23344 from tacaswell/auto-backport-of-pr-23333-on-v3.5.x
Backport PR#23333: Fix errorbar handling of nan.
2 parents56b0ad4 +82a60d8 commit40544ec

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

‎lib/matplotlib/axes/_axes.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,13 +1060,14 @@ def hlines(self, y, xmin, xmax, colors=None, linestyles='solid',
10601060
lines.update(kwargs)
10611061

10621062
iflen(y)>0:
1063-
minx=min(xmin.min(),xmax.min())
1064-
maxx=max(xmin.max(),xmax.max())
1065-
miny=y.min()
1066-
maxy=y.max()
1067-
1063+
# Extreme values of xmin/xmax/y. Using masked_verts here handles
1064+
# the case of y being a masked *object* array (as can be generated
1065+
# e.g. by errorbar()), which would make nanmin/nanmax stumble.
1066+
minx=np.nanmin(masked_verts[...,0])
1067+
maxx=np.nanmax(masked_verts[...,0])
1068+
miny=np.nanmin(masked_verts[...,1])
1069+
maxy=np.nanmax(masked_verts[...,1])
10681070
corners= (minx,miny), (maxx,maxy)
1069-
10701071
self.update_datalim(corners)
10711072
self._request_autoscale_view()
10721073

@@ -1139,11 +1140,13 @@ def vlines(self, x, ymin, ymax, colors=None, linestyles='solid',
11391140
lines.update(kwargs)
11401141

11411142
iflen(x)>0:
1142-
minx=x.min()
1143-
maxx=x.max()
1144-
miny=min(ymin.min(),ymax.min())
1145-
maxy=max(ymin.max(),ymax.max())
1146-
1143+
# Extreme values of x/ymin/ymax. Using masked_verts here handles
1144+
# the case of x being a masked *object* array (as can be generated
1145+
# e.g. by errorbar()), which would make nanmin/nanmax stumble.
1146+
minx=np.nanmin(masked_verts[...,0])
1147+
maxx=np.nanmax(masked_verts[...,0])
1148+
miny=np.nanmin(masked_verts[...,1])
1149+
maxy=np.nanmax(masked_verts[...,1])
11471150
corners= (minx,miny), (maxx,maxy)
11481151
self.update_datalim(corners)
11491152
self._request_autoscale_view()

‎lib/matplotlib/tests/test_axes.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3633,6 +3633,20 @@ def test_errorbar_linewidth_type(elinewidth):
36333633
plt.errorbar([1,2,3], [1,2,3],yerr=[1,2,3],elinewidth=elinewidth)
36343634

36353635

3636+
@check_figures_equal(extensions=["png"])
3637+
deftest_errorbar_nan(fig_test,fig_ref):
3638+
ax=fig_test.add_subplot()
3639+
xs=range(5)
3640+
ys=np.array([1,2,np.nan,np.nan,3])
3641+
es=np.array([4,5,np.nan,np.nan,6])
3642+
ax.errorbar(xs,ys,es)
3643+
ax=fig_ref.add_subplot()
3644+
ys=np.array([1,2,np.nan,np.nan,3])
3645+
es=np.array([4,5,np.nan,np.nan,6])
3646+
ax.errorbar([0,1], [1,2], [4,5])
3647+
ax.errorbar([4], [3], [6],fmt="C0")
3648+
3649+
36363650
@image_comparison(['hist_stacked_stepfilled','hist_stacked_stepfilled'])
36373651
deftest_hist_stacked_stepfilled():
36383652
# make some data

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp