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

Skip to content

Commit f2aea5b

Browse files
committed
boxplot and bxp docstrings to a more numpy-like format
1 parent f26a402 commit f2aea5b

1 file changed

Lines changed: 70 additions & 56 deletions

File tree

lib/matplotlib/axes/_axes.py

Lines changed: 70 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2798,47 +2798,51 @@ def boxplot(self, x, notch=False, sym='b+', vert=True, whis=1.5,
27982798
27992799
Call signature::
28002800
2801-
boxplot(x, notch=False, sym='+', vert=True, whis=1.5,
2801+
boxplot(x, notch=False, sym='b+', vert=True, whis=1.5,
28022802
positions=None, widths=None, patch_artist=False,
2803-
bootstrap=None, usermedians=None, conf_intervals=None)
2803+
bootstrap=None, usermedians=None, conf_intervals=None,
2804+
meanline=False, showmeans=False, showcaps=True,
2805+
showbox=True, showfliers=True, boxprops=None, labels=None,
2806+
flierprops=None, medianprops=None, meanprops=None)
28042807
28052808
Make a box and whisker plot for each column of *x* or each
28062809
vector in sequence *x*. The box extends from the lower to
28072810
upper quartile values of the data, with a line at the median.
28082811
The whiskers extend from the box to show the range of the
28092812
data. Flier points are those past the end of the whiskers.
28102813
2811-
Function Arguments:
2814+
Parameters
2815+
----------
28122816
2813-
*x* :
2814-
Array or a sequence of vectors.
2817+
x : Array or a sequence of vectors.
2818+
The input data.
28152819
2816-
*notch* : [ False (default) | True ]
2817-
If False (default), produces a rectangular box plot.
2820+
notch : bool, default = False
2821+
If False, produces a rectangular box plot.
28182822
If True, will produce a notched box plot
28192823
2820-
*sym* : [ default 'b+' ]
2824+
sym : str, default = 'b+'
28212825
The default symbol for flier points.
28222826
Enter an empty string ('') if you don't want to show fliers.
28232827
2824-
*vert* : [ False | True (default) ]
2828+
vert : bool, default = False
28252829
If True (default), makes the boxes vertical.
28262830
If False, makes horizontal boxes.
28272831
2828-
*whis* : [ float | string | or sequence (default = 1.5) ]
2832+
whis : float, sequence (default = 1.5) or string
28292833
As a float, determines the reach of the whiskers past the first
28302834
and third quartiles (e.g., Q3 + whis*IQR, IQR = interquartile
28312835
range, Q3-Q1). Beyond the whiskers, data are considered outliers
28322836
and are plotted as individual points. Set this to an unreasonably
28332837
high value to force the whiskers to show the min and max values.
28342838
Alternatively, set this to an ascending sequence of percentile
28352839
(e.g., [5, 95]) to set the whiskers at specific percentiles of
2836-
the data. Finally, can *whis* be the string 'range' to force the
2840+
the data. Finally, *whis* can be the string 'range' to force the
28372841
whiskers to the min and max of the data. In the edge case that
28382842
the 25th and 75th percentiles are equivalent, *whis* will be
28392843
automatically set to 'range'.
28402844
2841-
*bootstrap* : [ *None* (default) | integer ]
2845+
bootstrap : None (default) or integer
28422846
Specifies whether to bootstrap the confidence intervals
28432847
around the median for notched boxplots. If bootstrap==None,
28442848
no bootstrapping is performed, and notches are calculated
@@ -2848,69 +2852,72 @@ def boxplot(self, x, notch=False, sym='b+', vert=True, whis=1.5,
28482852
bootstrap the median to determine it's 95% confidence intervals.
28492853
Values between 1000 and 10000 are recommended.
28502854
2851-
*usermedians* : [ default None ]
2855+
usermedians : array-like or None (default)
28522856
An array or sequence whose first dimension (or length) is
28532857
compatible with *x*. This overrides the medians computed by
28542858
matplotlib for each element of *usermedians* that is not None.
28552859
When an element of *usermedians* == None, the median will be
2856-
computed directly as normal.
2860+
computed by matplotlib as normal.
28572861
2858-
*conf_intervals* : [ default None ]
2862+
conf_intervals : array-like or None (default)
28592863
Array or sequence whose first dimension (or length) is compatible
28602864
with *x* and whose second dimension is 2. When the current element
28612865
of *conf_intervals* is not None, the notch locations computed by
28622866
matplotlib are overridden (assuming notch is True). When an
28632867
element of *conf_intervals* is None, boxplot compute notches the
28642868
method specified by the other kwargs (e.g., *bootstrap*).
28652869
2866-
*positions* : [ default 1,2,...,n ]
2867-
Sets the horizontal positions of the boxes. The ticks and limits
2870+
positions : array-like, default = [1, 2, ..., n]
2871+
Sets the positions of the boxes. The ticks and limits
28682872
are automatically set to match the positions.
28692873
2870-
*widths* : [ default 0.5 ]
2874+
widths : array-like, default = 0.5
28712875
Either a scalar or a vector and sets the width of each box. The
28722876
default is 0.5, or ``0.15*(distance between extreme positions)``
28732877
if that is smaller.
28742878
2875-
*labels* : [ sequence | None (default) ]
2879+
labels : sequence or None (default)
28762880
Labels for each dataset. Length must be compatible with
28772881
dimensions of *x*
28782882
2879-
*patch_artist* : [ False (default) | True ]
2883+
patch_artist : bool, default = False
28802884
If False produces boxes with the Line2D artist
28812885
If True produces boxes with the Patch artist
28822886
2883-
*showmeans* : [ False (default) | True ]
2887+
showmeans : bool, default = False
28842888
If True, will toggle one the rendering of the means
28852889
2886-
*showcaps* : [ False | True (default) ]
2890+
showcaps : bool, default = True
28872891
If True, will toggle one the rendering of the caps
28882892
2889-
*showbox* : [ False | True (default) ]
2893+
showbox : bool, default = True
28902894
If True, will toggle one the rendering of box
28912895
2892-
*showfliers* : [ False | True (default) ]
2896+
showfliers : bool, default = True
28932897
If True, will toggle one the rendering of the fliers
28942898
2895-
*boxprops* : [ dict | None (default) ]
2899+
boxprops : dict or None (default)
28962900
If provided, will set the plotting style of the boxes
28972901
2898-
*flierprops* : [ dict | None (default) ]
2902+
flierprops : dict or None (default)
28992903
If provided, will set the plotting style of the fliers
29002904
2901-
*medianprops* : [ dict | None (default) ]
2905+
medianprops : dict or None (default)
29022906
If provided, will set the plotting style of the medians
29032907
2904-
*meanprops* : [ dict | None (default) ]
2908+
meanprops : dict or None (default)
29052909
If provided, will set the plotting style of the means
29062910
2907-
*meanline* : [ False (default) | True ]
2911+
meanline : bool, default = False
29082912
If True (and *showmeans* is True), will try to render the mean
29092913
as a line spanning the full width of the box according to
29102914
*meanprops*. Not recommended if *shownotches* is also True.
29112915
Otherwise, means will be shown as points.
29122916
2913-
Returns a dictionary mapping each component of the boxplot
2917+
Returns
2918+
-------
2919+
2920+
A dictionary mapping each component of the boxplot
29142921
to a list of the :class:`matplotlib.lines.Line2D`
29152922
instances created. That dictionary has the following keys
29162923
(assuming vertical boxplots):
@@ -2925,9 +2932,10 @@ def boxplot(self, x, notch=False, sym='b+', vert=True, whis=1.5,
29252932
whiskers (outliers).
29262933
- means: points or lines representing the means.
29272934
2928-
**Example:**
2935+
Examples
2936+
--------
29292937
2930-
.. plot:: pyplots/boxplot_demo.py
2938+
.. plot:: examples/statistics/boxplot_demo.py
29312939
"""
29322940
bxpstats = cbook.boxplot_stats(x, whis=whis, bootstrap=bootstrap,
29332941
labels=labels)
@@ -2982,20 +2990,22 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
29822990
29832991
Call signature::
29842992
2985-
bxp(self, bxpstats, positions=None, widths=None, vert=True,
2993+
bxp(bxpstats, positions=None, widths=None, vert=True,
29862994
patch_artist=False, shownotches=False, showmeans=False,
2987-
showcaps=True, showbox=True, boxprops=None, flierprops=None,
2988-
medianprops=None, meanprops=None, meanline=False):
2995+
showcaps=True, showbox=True, showfliers=True,
2996+
boxprops=None, flierprops=None, medianprops=None,
2997+
meanprops=None, meanline=False)
29892998
29902999
Make a box and whisker plot for each column of *x* or each
29913000
vector in sequence *x*. The box extends from the lower to
29923001
upper quartile values of the data, with a line at the median.
29933002
The whiskers extend from the box to show the range of the
29943003
data. Flier points are those past the end of the whiskers.
29953004
2996-
Function Arguments:
3005+
Parameters
3006+
----------
29973007
2998-
*bxpstats* :
3008+
bxpstats : list of dicts
29993009
A list of dictionaries containing stats for each boxplot.
30003010
Required keys are:
30013011
'med' - The median (scalar float).
@@ -3012,58 +3022,61 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
30123022
'label' - Name of the dataset (string). If available, this
30133023
will be used a tick label for the boxplot
30143024
3015-
*positions* : [ default 1,2,...,n ]
3016-
Sets the horizontal positions of the boxes. The ticks and limits
3025+
positions : array-like, default = [1, 2, ..., n]
3026+
Sets the positions of the boxes. The ticks and limits
30173027
are automatically set to match the positions.
30183028
3019-
*widths* : [ default 0.5 ]
3029+
widths : array-like, default = 0.5
30203030
Either a scalar or a vector and sets the width of each box. The
30213031
default is 0.5, or ``0.15*(distance between extreme positions)``
30223032
if that is smaller.
30233033
3024-
*vert* : [ False | True (default) ]
3034+
vert : bool, default = False
30253035
If True (default), makes the boxes vertical.
30263036
If False, makes horizontal boxes.
30273037
3028-
*patch_artist* : [ False (default) | True ]
3038+
patch_artist : bool, default = False
30293039
If False produces boxes with the Line2D artist
3030-
If True produces boxes with the Patch artist1
3040+
If True produces boxes with the Patch artist
30313041
3032-
*shownotches* : [ False (default) | True ]
3042+
shownotches : bool, default = False
30333043
If False (default), produces a rectangular box plot.
30343044
If True, will produce a notched box plot
30353045
3036-
*showmeans* : [ False (default) | True ]
3046+
showmeans : bool, default = False
30373047
If True, will toggle one the rendering of the means
30383048
3039-
*showcaps* : [ False | True (default) ]
3049+
showcaps : bool, default = True
30403050
If True, will toggle one the rendering of the caps
30413051
3042-
*showbox* : [ False | True (default) ]
3052+
showbox : bool, default = True
30433053
If True, will toggle one the rendering of box
30443054
3045-
*showfliers* : [ False | True (default) ]
3055+
showfliers : bool, default = True
30463056
If True, will toggle one the rendering of the fliers
30473057
3048-
*boxprops* : [ dict | None (default) ]
3058+
boxprops : dict or None (default)
30493059
If provided, will set the plotting style of the boxes
30503060
3051-
*flierprops* : [ dict | None (default) ]
3061+
flierprops : dict or None (default)
30523062
If provided, will set the plotting style of the fliers
30533063
3054-
*medianprops* : [ dict | None (default) ]
3064+
medianprops : dict or None (default)
30553065
If provided, will set the plotting style of the medians
30563066
3057-
*meanprops* : [ dict | None (default) ]
3067+
meanprops : dict or None (default)
30583068
If provided, will set the plotting style of the means
30593069
3060-
*meanline* : [ False (default) | True ]
3070+
meanline : bool, default = False
30613071
If True (and *showmeans* is True), will try to render the mean
30623072
as a line spanning the full width of the box according to
30633073
*meanprops*. Not recommended if *shownotches* is also True.
30643074
Otherwise, means will be shown as points.
30653075
3066-
Returns a dictionary mapping each component of the boxplot
3076+
Returns
3077+
-------
3078+
3079+
A dictionary mapping each component of the boxplot
30673080
to a list of the :class:`matplotlib.lines.Line2D`
30683081
instances created. That dictionary has the following keys
30693082
(assuming vertical boxplots):
@@ -3078,9 +3091,10 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
30783091
whiskers (fliers).
30793092
- means: points or lines representing the means.
30803093
3081-
**Example:**
3094+
Examples
3095+
--------
30823096
3083-
.. plot:: pyplots/boxplot_demo.py
3097+
.. plot:: examples/statistics/bxp_demo.py
30843098
"""
30853099
# lists of artists to be output
30863100
whiskers = []

0 commit comments

Comments
 (0)