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

Commitc519536

Browse files
authored
Merge pull request#24151 from meeseeksmachine/auto-backport-of-pr-24149-on-v3.6.x
Backport PR#24149 on branch v3.6.x (FIX: handle input to ax.bar that is all nan)
2 parents3d2bbe3 +e6dd37b commitc519536

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

‎lib/matplotlib/axes/_axes.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,11 +2182,19 @@ def _convert_dx(dx, x0, xconv, convert):
21822182
x0=cbook._safe_first_finite(x0)
21832183
except (TypeError,IndexError,KeyError):
21842184
pass
2185+
exceptStopIteration:
2186+
# this means we found no finite element, fall back to first
2187+
# element unconditionally
2188+
x0=cbook.safe_first_element(x0)
21852189

21862190
try:
21872191
x=cbook._safe_first_finite(xconv)
21882192
except (TypeError,IndexError,KeyError):
21892193
x=xconv
2194+
exceptStopIteration:
2195+
# this means we found no finite element, fall back to first
2196+
# element unconditionally
2197+
x=cbook.safe_first_element(xconv)
21902198

21912199
delist=False
21922200
ifnotnp.iterable(dx):

‎lib/matplotlib/tests/test_axes.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8144,3 +8144,16 @@ def test_bar_leading_nan():
81448144
forbinrest:
81458145
assertnp.isfinite(b.xy).all()
81468146
assertnp.isfinite(b.get_width())
8147+
8148+
8149+
@check_figures_equal(extensions=["png"])
8150+
deftest_bar_all_nan(fig_test,fig_ref):
8151+
mpl.style.use("mpl20")
8152+
ax_test=fig_test.subplots()
8153+
ax_ref=fig_ref.subplots()
8154+
8155+
ax_test.bar([np.nan], [np.nan])
8156+
ax_test.bar([1], [1])
8157+
8158+
ax_ref.bar([1], [1]).remove()
8159+
ax_ref.bar([1], [1])

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp