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

Commit8ed7c78

Browse files
authored
Merge pull request#15140 from dstansby/mask-fmt
FIX: ScalarFormatter formatting of masked values
2 parents18a30ce +2b02440 commit8ed7c78

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

‎lib/matplotlib/tests/test_image.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,3 +1103,18 @@ def test_respects_bbox():
11031103
buf_after=io.BytesIO()
11041104
fig.savefig(buf_after,format="rgba")
11051105
assertbuf_before.getvalue()!=buf_after.getvalue()# Not all white.
1106+
1107+
1108+
deftest_image_cursor_formatting():
1109+
fig,ax=plt.subplots()
1110+
# Create a dummy image to be able to call format_cursor_data
1111+
im=ax.imshow(np.zeros((4,4)))
1112+
1113+
data=np.ma.masked_array([0],mask=[True])
1114+
assertim.format_cursor_data(data)=='[]'
1115+
1116+
data=np.ma.masked_array([0],mask=[False])
1117+
assertim.format_cursor_data(data)=='[0]'
1118+
1119+
data=np.nan
1120+
assertim.format_cursor_data(data)=='[nan]'

‎lib/matplotlib/ticker.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,8 @@ def format_data_short(self, value):
629629
"""
630630
ifself._useLocale:
631631
returnlocale.format_string('%-12g', (value,))
632+
elifisinstance(value,np.ma.MaskedArray)andvalue.mask:
633+
return''
632634
else:
633635
return'%-12g'%value
634636

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp