Skip to content

Commit 855448d

Browse files
committed
Added plot in boxplot_frame_groupby example
1 parent f81fb81 commit 855448d

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

pandas/plotting/_core.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -547,18 +547,25 @@ def boxplot_frame_groupby(
547547
548548
Examples
549549
--------
550-
>>> import itertools
551-
>>> from pandas.plotting import boxplot_frame_groupby
552-
>>> tuples = [t for t in itertools.product(range(1000), range(4))]
553-
>>> index = pd.MultiIndex.from_tuples(tuples, names=['lvl0', 'lvl1'])
554-
>>> data = np.random.randn(len(index),4)
555-
>>> df = pd.DataFrame(data, columns=list('ABCD'), index=index)
556-
>>>
557-
>>> grouped = df.groupby(level='lvl1')
558-
>>> boxplot_frame_groupby(grouped)
559-
>>>
560-
>>> grouped = df.unstack(level='lvl1').groupby(level=0, axis=1)
561-
>>> boxplot_frame_groupby(grouped, subplots=False)
550+
You can create boxplots for grouped data and show them as separate subplots:
551+
552+
.. plot::
553+
:context: close-figs
554+
555+
>>> import itertools
556+
>>> from pandas.plotting import boxplot_frame_groupby
557+
>>> tuples = [t for t in itertools.product(range(1000), range(4))]
558+
>>> index = pd.MultiIndex.from_tuples(tuples, names=['lvl0', 'lvl1'])
559+
>>> data = np.random.randn(len(index),4)
560+
>>> df = pd.DataFrame(data, columns=list('ABCD'), index=index)
561+
>>> grouped = df.groupby(level='lvl1')
562+
>>> boxplot_frame_groupby(grouped, rot=45, fontsize=12)
563+
The ``subplots=False`` option shows the boxplots in a single figure.
564+
565+
.. plot::
566+
:context: close-figs
567+
568+
>>> boxplot_frame_groupby(grouped, subplots=False, rot=45, fontsize=12)
562569
"""
563570
plot_backend = _get_plot_backend(backend)
564571
return plot_backend.boxplot_frame_groupby(

0 commit comments

Comments
 (0)