@@ -1935,9 +1935,16 @@ def plot_series(data, kind='line', ax=None, # Series unique
1935
1935
1936
1936
1937
1937
_shared_docs ['boxplot' ] = """
1938
- Make a box plot from DataFrame column optionally grouped by some columns or
1939
- other inputs
1940
-
1938
+ Make a box-and-whisker plot from DataFrame column optionally grouped by some columns
1939
+ or other inputs. The box extends from the Q1 to Q3 quartile values of the data,
1940
+ with a line at the median (Q2). The whiskers extend from the edges of
1941
+ box to show the range of the data.
1942
+ Flier points (outliers) are those past the end of the whiskers.
1943
+ The position of the whiskers is set by default to 1.5 IQR (whis=1.5)
1944
+ from the edge of the box.
1945
+ `
1946
+ For further details see `boxplot <https://en.wikipedia.org/wiki/Box_plot>`__
1947
+
1941
1948
Parameters
1942
1949
----------
1943
1950
data : the pandas object holding the data
@@ -1958,29 +1965,53 @@ def plot_series(data, kind='line', ax=None, # Series unique
1958
1965
'dict' returns a dictionary whose values are the matplotlib
1959
1966
Lines of the boxplot;
1960
1967
'both' returns a namedtuple with the axes and dict.
1961
-
1962
1968
When grouping with ``by``, a Series mapping columns to ``return_type``
1963
1969
is returned, unless ``return_type`` is None, in which case a NumPy
1964
1970
array of axes is returned with the same shape as ``layout``.
1965
1971
See the prose documentation for more.
1966
-
1967
1972
`**kwds` : Keyword Arguments
1968
1973
All other plotting keyword arguments to be passed to
1969
- matplotlib's boxplot function
1970
-
1974
+ matplotlib's `boxplot <https://matplotlib.org/api/
1975
+ _as_gen/matplotlib.pyplot.boxplot.html>`
1976
+ function.
1971
1977
Returns
1972
1978
-------
1973
1979
lines : dict
1974
1980
ax : matplotlib Axes
1975
1981
(ax, lines): namedtuple
1976
-
1977
1982
Notes
1978
1983
-----
1979
1984
Use ``return_type='dict'`` when you want to tweak the appearance
1980
1985
of the lines after plotting. In this case a dict containing the Lines
1981
1986
making up the boxes, caps, fliers, medians, and whiskers is returned.
1982
- """
1983
1987
1988
+ >>> df = pd.DataFrame({u'stratifying_var': np.random.uniform(0, 100, 20),
1989
+ u'price': np.random.normal(100, 5, 20),
1990
+ u'demand': np.random.normal(100, 10, 20)})
1991
+
1992
+ >>> df[u'quartiles'] = pd.qcut(df[u'stratifying_var'], 4,
1993
+ labels=[u'0-25%', u'25-50%', u'50-75%', u'75-100%'])
1994
+
1995
+ >>> df
1996
+
1997
+ To plot the boxplot of the `demand` just put:
1998
+
1999
+ >>> df.boxplot(column=u'demand', by=u'quartiles')
2000
+
2001
+ Use `grid=False` to hide the grid:
2002
+
2003
+ >>> df.boxplot(column=u'demand', by=u'quartiles',grid=False)
2004
+
2005
+ Optionally, the layout can be changed by setting `layout=(rows, cols)`:
2006
+
2007
+ >>> df.boxplot(column=[u'price',u'demand'], by=u'quartiles', layout=(1,2),
2008
+ figsize=(8,5))
2009
+
2010
+
2011
+ >>> df.boxplot(column=[u'price',u'demand'], by=u'quartiles', layout=(2,1),
2012
+ figsize=(5,8))
2013
+
2014
+ """
1984
2015
1985
2016
@Appender (_shared_docs ['boxplot' ] % _shared_doc_kwargs )
1986
2017
def boxplot (data , column = None , by = None , ax = None , fontsize = None ,
0 commit comments