@@ -1689,16 +1689,34 @@ def boxplot(data, column=None, by=None, ax=None, fontsize=None,
1689
1689
data = DataFrame ({'x' : data })
1690
1690
column = 'x'
1691
1691
1692
+
1693
+ def _get_colors ():
1694
+ import matplotlib .pyplot as plt
1695
+ cycle = plt .rcParams .get ('axes.color_cycle' , list ('bgrcmyk' ))
1696
+ if isinstance (cycle , basestring ):
1697
+ cycle = list (cycle )
1698
+ colors = kwds .get ('color' , cycle )
1699
+ return colors
1700
+
1701
+ def maybe_color_bp (bp ):
1702
+ if 'color' not in kwds :
1703
+ from matplotlib .artist import setp
1704
+ setp (bp ['boxes' ],color = colors [0 ],alpha = 1 )
1705
+ setp (bp ['whiskers' ],color = colors [0 ],alpha = 1 )
1706
+ setp (bp ['medians' ],color = colors [2 ],alpha = 1 )
1707
+
1692
1708
def plot_group (grouped , ax ):
1693
1709
keys , values = zip (* grouped )
1694
1710
keys = [com .pprint_thing (x ) for x in keys ]
1695
1711
values = [remove_na (v ) for v in values ]
1696
- ax .boxplot (values , ** kwds )
1712
+ bp = ax .boxplot (values , ** kwds )
1697
1713
if kwds .get ('vert' , 1 ):
1698
1714
ax .set_xticklabels (keys , rotation = rot , fontsize = fontsize )
1699
1715
else :
1700
1716
ax .set_yticklabels (keys , rotation = rot , fontsize = fontsize )
1717
+ maybe_color_bp (bp )
1701
1718
1719
+ colors = _get_colors ()
1702
1720
if column is None :
1703
1721
columns = None
1704
1722
else :
@@ -1731,7 +1749,10 @@ def plot_group(grouped, ax):
1731
1749
# Return boxplot dict in single plot case
1732
1750
1733
1751
clean_values = [remove_na (x ) for x in data [cols ].values .T ]
1752
+
1734
1753
bp = ax .boxplot (clean_values , ** kwds )
1754
+ maybe_color_bp (bp )
1755
+
1735
1756
if kwds .get ('vert' , 1 ):
1736
1757
ax .set_xticklabels (keys , rotation = rot , fontsize = fontsize )
1737
1758
else :
0 commit comments