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

Skip to content

Commit a17f9d7

Browse files
committed
Add sharex and sharey to grouped boxplot
sharex and sharey should be settable and by default False in a grouped boxplot. E.g. In [97]: df = DataFrame(np.random.rand(10,2), columns=['Col1', 'Col2'] ) In [98]: df['X'] =['A','A','A','A','A','B','B','B','B','B'] In [99]: df.iloc[0:5, :2] += 10000 In [100]: df.groupby('X').boxplot() # this is unreadable
1 parent 1eb9955 commit a17f9d7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pandas/tools/plotting.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2685,7 +2685,7 @@ def plot_group(group, ax):
26852685

26862686
def boxplot_frame_groupby(grouped, subplots=True, column=None, fontsize=None,
26872687
rot=0, grid=True, ax=None, figsize=None,
2688-
layout=None, **kwds):
2688+
layout=None, sharex=False, sharey=False, **kwds):
26892689
"""
26902690
Make box plots from DataFrameGroupBy data.
26912691
@@ -2703,6 +2703,8 @@ def boxplot_frame_groupby(grouped, subplots=True, column=None, fontsize=None,
27032703
figsize : A tuple (width, height) in inches
27042704
layout : tuple (optional)
27052705
(rows, columns) for the layout of the plot
2706+
sharex: boolean, default False
2707+
sharey: boolean, default False
27062708
kwds : other plotting keyword arguments to be passed to matplotlib boxplot
27072709
function
27082710
@@ -2732,7 +2734,7 @@ def boxplot_frame_groupby(grouped, subplots=True, column=None, fontsize=None,
27322734
naxes = len(grouped)
27332735
nrows, ncols = _get_layout(naxes, layout=layout)
27342736
fig, axes = _subplots(nrows=nrows, ncols=ncols, naxes=naxes, squeeze=False,
2735-
ax=ax, sharex=False, sharey=True, figsize=figsize)
2737+
ax=ax, sharex=sharex, sharey=sharey, figsize=figsize)
27362738
axes = _flatten(axes)
27372739

27382740
ret = compat.OrderedDict()

0 commit comments

Comments
 (0)