10000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b99e636 commit c250254Copy full SHA for c250254
lib/matplotlib/units.py
@@ -160,13 +160,16 @@ def get_converter(self, x):
160
x = x.values
161
162
# If x is an array, look inside the array for data with units
163
- if isinstance(x, np.ndarray) and x.size:
+ if isinstance(x, np.ndarray):
164
+ # If there are no elements in x, infer the units from its dtype
165
+ if not x.size:
166
+ return self.get_converter(np.array([0], dtype=x.dtype))
167
xravel = x.ravel()
168
try:
169
# pass the first value of x that is not masked back to
170
# get_converter
171
if not np.all(xravel.mask):
- # some elements are not masked
172
+ # Get first non-masked item
173
converter = self.get_converter(
174
xravel[np.argmin(xravel.mask)])
175
return converter
0 commit comments