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

Commit2896fc1

Browse files
authored
Merge pull request#28656 from meeseeksmachine/auto-backport-of-pr-28649-on-v3.9.x
Backport PR#28649 on branch v3.9.x (FIX: improve formatting of image values in cases of singular norms)
2 parentsecb6098 +e7aba70 commit2896fc1

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

‎lib/matplotlib/artist.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,9 @@ def format_cursor_data(self, data):
13461346
delta=np.diff(
13471347
self.norm.boundaries[neigh_idx:cur_idx+2]
13481348
).max()
1349-
1349+
elifself.norm.vmin==self.norm.vmax:
1350+
# singular norms, use delta of 10% of only value
1351+
delta=np.abs(self.norm.vmin*.1)
13501352
else:
13511353
# Midpoints of neighboring color intervals.
13521354
neighbors=self.norm.inverse(

‎lib/matplotlib/cbook.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,6 +2252,10 @@ def _g_sig_digits(value, delta):
22522252
it is known with an error of *delta*.
22532253
"""
22542254
ifdelta==0:
2255+
ifvalue==0:
2256+
# if both value and delta are 0, np.spacing below returns 5e-324
2257+
# which results in rather silly results
2258+
return3
22552259
# delta = 0 may occur when trying to format values over a tiny range;
22562260
# in that case, replace it by the distance to the closest float.
22572261
delta=abs(np.spacing(value))

‎lib/matplotlib/tests/test_image.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,8 @@ def test_cursor_data_nonuniform(xy, data):
411411
([[.123,.987]],"[0.123]"),
412412
([[np.nan,1,2]],"[]"),
413413
([[1,1+1e-15]],"[1.0000000000000000]"),
414-
([[-1,-1]],"[-1.0000000000000000]"),
414+
([[-1,-1]],"[-1.0]"),
415+
([[0,0]],"[0.00]"),
415416
])
416417
deftest_format_cursor_data(data,text):
417418
frommatplotlib.backend_basesimportMouseEvent

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp