Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3f3b92f

Browse files
committed
Merge pull request #4953 from jenshnielsen/format_cursor_data_fix_4806
FIX: Make sure that data is a number before formatting Fix for #4806
2 parents 677646e + e1d30c8 commit 3f3b92f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/matplotlib/artist.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import re
77
import warnings
88
import inspect
9+
import numpy as np
910
import matplotlib
1011
import matplotlib.cbook as cbook
1112
from matplotlib.cbook import mplDeprecation
@@ -988,7 +989,8 @@ def format_cursor_data(self, data):
988989
data[0]
989990
except (TypeError, IndexError):
990991
data = [data]
991-
return ', '.join('{:0.3g}'.format(item) for item in data)
992+
return ', '.join('{:0.3g}'.format(item) for item in data if
993+
isinstance(item, (np.floating, np.integer, int, float)))
992994

993995
@property
994996
def mouseover(self):

0 commit comments

Comments
 (0)