html)
  * [ Resampling ](../resampling.html)
  * [ Style ](../style.html)
  * [ Plotting ](../plotting.html)
  * [ Options and settings ](../options.html)
  * [ Extensions ](../extensions.html)
  * [ Testing ](../testing.html)
  * [ Missing values ](../missing_value.html)

  * [ __ ](../../index.html)
  * [ API reference ](../index.html)
  * [ DataFrame ](../frame.html)
  * pandas.DataF... 

#  pandas.DataFrame.plot.box  #

DataFrame.plot.  box  (  _ by  =  None  _ , _ **  kwargs  _ )  [ [source]
](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/plotting/_core.py#L1282-L1347) #

    

Make a box plot of the DataFrame columns.

A box plot is a method for graphically depicting groups of numerical data
through their quartiles. The box extends from the Q1 to Q3 quartile values of
the data, with a line at the median (Q2). The whiskers extend from the edges
of box to show the range of the data. The position of the whiskers is set by
default to 1.5*IQR (IQR = Q3 - Q1) from the edges of the box. Outlier points
are those past the end of the whiskers.

For further details see Wikipediaâs entry for [ boxplot
](https://en.wikipedia.org/wiki/Box_plot) .

A consideration when using this chart is that the box and the whiskers can
overlap, which is very common when plotting small sets of data.

Parameters  :

    

**by** str or sequence

    

Column in the DataFrame to group by.

Changed in version 1.4.0:  Previously,  by  is silently ignore and makes no
groupings

****kwargs**

    

Additional keywords are documented in [ ` DataFrame.plot()  `
](pandas.DataFrame.plot.html#pandas.DataFrame.plot "pandas.DataFrame.plot") .

Returns  :

    

[ ` matplotlib.axes.Axes  `
](https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes
"\(in Matplotlib v3.8.4\)") or numpy.ndarray of them

    

See also

[ ` DataFrame.boxplot  `
](pandas.DataFrame.boxplot.html#pandas.DataFrame.boxplot
"pandas.DataFrame.boxplot")

    

Another method to draw a box plot.

[ ` Series.plot.box  ` ](pandas.Series.plot.box.html#pandas.Series.plot.box
"pandas.Series.plot.box")

    

Draw a box plot from a Series object.

[ ` matplotlib.pyplot.boxplot  `
](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.boxplot.html#matplotlib.pyplot.boxplot
"\(in Matplotlib v3.8.4\)")

    

Draw a box plot in matplotlib.

Examples

Draw a box plot from a DataFrame with four columns of randomly generated data.

    
    
    >>> data = np.random.randn(25, 4)
    >>> df = pd.DataFrame(data, columns=list('ABCD'))
    >>> ax = df.plot.box()
    

![../../_images/pandas-DataFrame-plot-box-1.png](../../_images/pandas-
DataFrame-plot-box-1.png)

You can also generate groupings if you specify the  by  parameter (which can
take a column name, or a list or tuple of column names):

Changed in version 1.4.0.

    
    
    >>> age_list = [8, 10, 12, 14, 72, 74, 76, 78, 20, 25, 30, 35, 60, 85]
    >>> df = pd.DataFrame({"gender": list("MMMMMMMMFFFFFF"), "age": age_list})
    >>> ax = df.plot.box(column="age", by="gender", figsize=(10, 8))
    

![../../_images/pandas-DataFrame-plot-box-2.png](../../_images/pandas-
DataFrame-plot-box-2.png)

[ __ previous  pandas.DataFrame.plot.barh  ](pandas.DataFrame.plot.barh.html
"previous page") [ next  pandas.DataFrame.plot.density  __
](pandas.DataFrame.plot.density.html "next page")

__ On this page

  * ` DataFrame.plot.box()  `

[ __ Show Source
](../../_sources/reference/api/pandas.DataFrame.plot.box.rst.txt)

© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://www.ovhcloud.com) .

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.  

Built with the [ PyData Sphinx Theme ](https://pydata-sphinx-
theme.readthedocs.io/en/stable/index.html) 0.14.4.