Skip to content

Commit cdf5dad

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

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3643,12 +3643,12 @@ 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"))
3651-
3651+
36523652
# width
36533653
if widths is None:
36543654
widths = [np.clip(0.15 * np.ptp(positions), 0.15, 0.5)] * N

lib/matplotlib/axes/_base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3099,7 +3099,6 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False,
30993099
self._process_unit_info(xdata=(left, right))
31003100
left = self._validate_converted_limits(left, self.convert_xunits)
31013101
right = self._validate_converted_limits(right, self.convert_xunits)
3102-
31033102
old_left, old_right = self.get_xlim()
31043103
if left is None:
31053104
left = old_left

lib/matplotlib/axis.py

Lines changed: 5 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
@@ -1510,13 +1511,15 @@ def have_units(self):
15101511
def convert_units(self, x):
15111512
# If x is already a number, doesn't need converting
15121513
if munits.ConversionInterface.is_numlike(x):
1513-
return x
1514+
if isinstance(x, numbers.Number):
1515+
return x
1516+
return np.asarray(x)
15141517

15151518
if self.converter is None:
15161519
self.converter = munits.registry.get_converter(x)
15171520

15181521
if self.converter is None:
1519-
return x
1522+
return np.asarry(x)
15201523

15211524
ret = self.converter.convert(x, self.units, self)
15221525
return ret

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy