Skip to content

Commit 34f9ee0

Browse files
committed
FIX: let boxplot take pandas position
1 parent dfb8936 commit 34f9ee0

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3643,10 +3643,10 @@ def dopatch(xs, ys, **kwargs):
36433643
N = len(bxpstats)
36443644
datashape_message = ("List of boxplot statistics and `{0}` "
36453645
"values must have same the length")
3646-
# check position
36473646
if positions is None:
36483647
positions = list(range(1, N + 1))
3649-
elif len(positions) != N:
3648+
positions = self.convert_xunits(positions)
3649+
if len(positions) != N:
36503650
raise ValueError(datashape_message.format("positions"))
36513651

36523652
# width
@@ -5678,7 +5678,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
56785678

56795679
# convert to one dimensional arrays
56805680
C = C.ravel()
5681-
coords = np.column_stack((X, Y)).astype(float, copy=False)
5681+
coords = np.column_stack((X, Y)).astype(float)
56825682
collection = mcoll.QuadMesh(Nx - 1, Ny - 1, coords,
56835683
antialiased=antialiased, shading=shading,
56845684
**kwargs)

lib/matplotlib/axis.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import datetime
66
import logging
7+
import numbers
78
import warnings
89

910
import numpy as np
@@ -1508,9 +1509,14 @@ def have_units(self):
15081509
return self.converter is not None or self.units is not None
15091510

15101511
def convert_units(self, x):
1511-
# If x is already a number, doesn't need converting
1512+
# If x is already a number, doesn't need converting, but
1513+
# some iterables need to be massaged a bit...
15121514
if munits.ConversionInterface.is_numlike(x):
1513-
return x
1515+
if isinstance(x, list) or isinstance(x, numbers.Number):
1516+
return x
1517+
if issubclass(type(x), np.ma.MaskedArray):
1518+
return np.ma.asarray(x)
1519+
return np.asarray(x)
15141520

15151521
if self.converter is None:
15161522
self.converter = munits.registry.get_converter(x)

0 commit comments

Comments
 (0)