From 89a78481ec6fd38cd793d35929e78f76879f002c Mon Sep 17 00:00:00 2001 From: Lkxz Date: Thu, 15 Mar 2018 22:35:32 +0100 Subject: [PATCH 1/4] Extended documentation for pandas.DataFrame.plot.box --- pandas/plotting/_core.py | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index fa2766bb63d55..c1125bf8f28d3 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -3031,19 +3031,46 @@ def barh(self, x=None, y=None, **kwds): def box(self, by=None, **kwds): r""" - Boxplot + Make a box plot of the DataFrame columns. + + This method draws a box and whisker for each series in the DataFrame + in a single chart. The boxes share the vertical axis, which + makes makes it easier to compare if they are similar in scale. + Box plots are useful because they clearly show the median, + quartiles and flier points in the data. + + 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 : string or sequence Column in the DataFrame to group by. - `**kwds` : optional - Additional keyword arguments are documented in + **kwds : optional + Additional keywords are documented in :meth:`pandas.DataFrame.plot`. Returns ------- axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them + + See Also + -------- + :meth:`pandas.DataFrame.boxplot` : Another method to draw a box plot. + :meth:`pandas.Series.plot.box` : Draw a box plot from a Series object. + :func:`matplotlib.pyplot.boxplot`: Draw a box plot in matplotlib. + + Examples + -------- + Draw a box plot from a DataFrame with four columns of randomly + generated data. + + .. plot:: + :context: close-figs + + >>> data = np.random.randint(0, 10, size=(25, 4)) + >>> df = pd.DataFrame(data, columns=list('ABCD')) + >>> plot = df.plot.box() """ return self(kind='box', by=by, **kwds) From 3171a9765017c17750f17707a3083b685928f259 Mon Sep 17 00:00:00 2001 From: Lkxz Date: Fri, 16 Mar 2018 10:01:45 +0100 Subject: [PATCH 2/4] Feedback corrections --- pandas/plotting/_core.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index c1125bf8f28d3..1df7348b983e7 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -3033,11 +3033,16 @@ def box(self, by=None, **kwds): r""" Make a box plot of the DataFrame columns. - This method draws a box and whisker for each series in the DataFrame - in a single chart. The boxes share the vertical axis, which - makes makes it easier to compare if they are similar in scale. - Box plots are useful because they clearly show the median, - quartiles and flier points in the data. + 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 `_. 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. @@ -3056,9 +3061,9 @@ def box(self, by=None, **kwds): See Also -------- - :meth:`pandas.DataFrame.boxplot` : Another method to draw a box plot. - :meth:`pandas.Series.plot.box` : Draw a box plot from a Series object. - :func:`matplotlib.pyplot.boxplot`: Draw a box plot in matplotlib. + pandas.DataFrame.boxplot: Another method to draw a box plot. + pandas.Series.plot.box: Draw a box plot from a Series object. + matplotlib.pyplot.boxplot: Draw a box plot in matplotlib. Examples -------- @@ -3068,7 +3073,7 @@ def box(self, by=None, **kwds): .. plot:: :context: close-figs - >>> data = np.random.randint(0, 10, size=(25, 4)) + >>> data = np.random.randn(25, 4) >>> df = pd.DataFrame(data, columns=list('ABCD')) >>> plot = df.plot.box() """ From 49fe6f8468cd9f1c87eedf781aa06e8172d519a8 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Fri, 23 Mar 2018 10:03:40 +0100 Subject: [PATCH 3/4] Update _core.py --- pandas/plotting/_core.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 1df7348b983e7..d2eb776fed532 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -3033,8 +3033,8 @@ def box(self, by=None, **kwds): r""" Make a box plot of the DataFrame columns. - A box plot is a method for graphically depicting - groups of numerical data through their quartiles. + 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 @@ -3042,7 +3042,7 @@ def box(self, by=None, **kwds): box. Outlier points are those past the end of the whiskers. For further details see Wikipedia's - entry for `boxplot `_. + entry for `boxplot `__. 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. From 649aa129524f0137e5ed937987919d160621097a Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Fri, 23 Mar 2018 10:04:04 +0100 Subject: [PATCH 4/4] Update _core.py --- pandas/plotting/_core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index d2eb776fed532..2cc0944d29019 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -3075,7 +3075,7 @@ def box(self, by=None, **kwds): >>> data = np.random.randn(25, 4) >>> df = pd.DataFrame(data, columns=list('ABCD')) - >>> plot = df.plot.box() + >>> ax = df.plot.box() """ return self(kind='box', by=by, **kwds)