@@ -3043,9 +3043,10 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
3043
3043
positions = None , widths = None , patch_artist = None ,
3044
3044
bootstrap = None , usermedians = None , conf_intervals = None ,
3045
3045
meanline = None , showmeans = None , showcaps = None ,
3046
- showbox = None , showfliers = None , boxprops = None , labels = None ,
3047
- flierprops = None , medianprops = None , meanprops = None ,
3048
- capprops = None , whiskerprops = None , manage_xticks = True ):
3046
+ showbox = None , showfliers = None , boxprops = None ,
3047
+ labels = None , flierprops = None , medianprops = None ,
3048
+ meanprops = None , capprops = None , whiskerprops = None ,
3049
+ manage_xticks = True , autorange = False ):
3049
3050
"""
3050
3051
Make a box and whisker plot.
3051
3052
@@ -3055,161 +3056,167 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
3055
3056
positions=None, widths=None, patch_artist=False,
3056
3057
bootstrap=None, usermedians=None, conf_intervals=None,
3057
3058
meanline=False, showmeans=False, showcaps=True,
3058
- showbox=True, showfliers=True, boxprops=None, labels=None,
3059
- flierprops=None, medianprops=None, meanprops=None,
3060
- capprops=None, whiskerprops=None, manage_xticks=True):
3059
+ showbox=True, showfliers=True, boxprops=None,
3060
+ labels=None, flierprops=None, medianprops=None,
3061
+ meanprops=None, capprops=None, whiskerprops=None,
3062
+ manage_xticks=True, autorange=False):
3061
3063
3062
- Make a box and whisker plot for each column of *x* or each
3063
- vector in sequence *x* . The box extends from the lower to
3064
+ Make a box and whisker plot for each column of ``x`` or each
3065
+ vector in sequence ``x`` . The box extends from the lower to
3064
3066
upper quartile values of the data, with a line at the median.
3065
3067
The whiskers extend from the box to show the range of the
3066
3068
data. Flier points are those past the end of the whiskers.
3067
3069
3068
3070
Parameters
3069
3071
----------
3070
3072
x : Array or a sequence of vectors.
3071
- The input data.
3072
-
3073
- notch : bool, default = False
3074
- If False, produces a rectangular box plot.
3075
- If True, will produce a notched box plot
3076
-
3077
- sym : str or None, default = None
3078
- The default symbol for flier points.
3079
- Enter an empty string ('') if you don't want to show fliers.
3080
- If `None`, then the fliers default to 'b+' If you want more
3081
- control use the flierprops kwarg.
3082
-
3083
- vert : bool, default = True
3084
- If True (default), makes the boxes vertical.
3085
- If False, makes horizontal boxes.
3086
-
3087
- whis : float, sequence (default = 1.5) or string
3088
- As a float, determines the reach of the whiskers past the first
3089
- and third quartiles (e.g., Q3 + whis*IQR, IQR = interquartile
3090
- range, Q3-Q1). Beyond the whiskers, data are considered outliers
3091
- and are plotted as individual points. Set this to an unreasonably
3092
- high value to force the whiskers to show the min and max values.
3093
- Alternatively, set this to an ascending sequence of percentile
3094
- (e.g., [5, 95]) to set the whiskers at specific percentiles of
3095
- the data. Finally, *whis* can be the string 'range' to force the
3096
- whiskers to the min and max of the data. In the edge case that
3097
- the 25th and 75th percentiles are equivalent, *whis* will be
3098
- automatically set to 'range'.
3099
-
3100
- bootstrap : None (default) or integer
3101
- Specifies whether to bootstrap the confidence intervals
3102
- around the median for notched boxplots. If bootstrap==None,
3103
- no bootstrapping is performed, and notches are calculated
3104
- using a Gaussian-based asymptotic approximation (see McGill, R.,
3105
- Tukey, J.W., and Larsen, W.A., 1978, and Kendall and Stuart,
3106
- 1967). Otherwise, bootstrap specifies the number of times to
3107
- bootstrap the median to determine it's 95% confidence intervals.
3108
- Values between 1000 and 10000 are recommended.
3109
-
3110
- usermedians : array-like or None (default)
3111
- An array or sequence whose first dimension (or length) is
3112
- compatible with *x*. This overrides the medians computed by
3113
- matplotlib for each element of *usermedians* that is not None.
3114
- When an element of *usermedians* == None, the median will be
3115
- computed by matplotlib as normal.
3116
-
3117
- conf_intervals : array-like or None (default)
3118
- Array or sequence whose first dimension (or length) is compatible
3119
- with *x* and whose second dimension is 2. When the current element
3120
- of *conf_intervals* is not None, the notch locations computed by
3121
- matplotlib are overridden (assuming notch is True). When an
3122
- element of *conf_intervals* is None, boxplot compute notches the
3123
- method specified by the other kwargs (e.g., *bootstrap*).
3124
-
3125
- positions : array-like, default = [1, 2, ..., n]
3126
- Sets the positions of the boxes. The ticks and limits
3127
- are automatically set to match the positions.
3128
-
3129
- widths : array-like, default = 0.5
3130
- Either a scalar or a vector and sets the width of each box. The
3131
- default is 0.5, or ``0.15*(distance between extreme positions)``
3132
- if that is smaller.
3133
-
3134
- labels : sequence or None (default)
3135
- Labels for each dataset. Length must be compatible with
3136
- dimensions of *x*
3137
-
3138
- patch_artist : bool, default = False
3139
- If False produces boxes with the Line2D artist
3140
- If True produces boxes with the Patch artist
3141
-
3142
- showmeans : bool, default = False
3143
- If True, will toggle on the rendering of the means
3144
-
3145
- showcaps : bool, default = True
3146
- If True, will toggle on the rendering of the caps
3147
-
3148
- showbox : bool, default = True
3149
- If True, will toggle on the rendering of the box
3150
-
3151
- showfliers : bool, default = True
3152
- If True, will toggle on the rendering of the fliers
3153
-
3154
- boxprops : dict or None (default)
3155
- If provided, will set the plotting style of the boxes
3156
-
3157
- whiskerprops : dict or None (default)
3158
- If provided, will set the plotting style of the whiskers
3073
+ The input data.
3074
+
3075
+ notch : bool, optional (False)
3076
+ If `True`, will produce a notched box plot. Otherwise, a
3077
+ rectangular boxplot is produced.
3078
+
3079
+ sym : str, optional
3080
+ The default symbol for flier points. Enter an empty string
3081
+ ('') if you don't want to show fliers. If `None`, then the
3082
+ fliers default to 'b+' If you want more control use the
3083
+ flierprops kwarg.
3084
+
3085
+ vert : bool, optional (True)
3086
+ If `True` (default), makes the boxes vertical. If `False`,
3087
+ everything is drawn horizontally.
3088
+
3089
+ whis : float, sequence, or string (default = 1.5)
3090
+ As a float, determines the reach of the whiskers past the
3091
+ first and third quartiles (e.g., Q3 + whis*IQR,
3092
+ IQR = interquartile range, Q3-Q1). Beyond the whiskers, data
3093
+ are considered outliers and are plotted as individual
3094
+ points. Set this to an unreasonably high value to force the
3095
+ whiskers to show the min and max values. Alternatively, set
3096
+ this to an ascending sequence of percentile (e.g., [5, 95])
3097
+ to set the whiskers at specific percentiles of the data.
3098
+ Finally, ``whis`` can be the string ``'range'`` to force the
3099
+ whiskers to the min and max of the data.
3100
+
3101
+ bootstrap : int, optional
3102
+ Specifies whether to bootstrap the confidence intervals
3103
+ around the median for notched boxplots. If `bootstrap` is None,
3104
+ no bootstrapping is performed, and notches are calculated
3105
+ using a Gaussian-based asymptotic approximation (see McGill,
3106
+ R., Tukey, J.W., and Larsen, W.A., 1978, and Kendall and
3107
+ Stuart, 1967). Otherwise, bootstrap specifies the number of
3108
+ times to bootstrap the median to determine its 95%
3109
+ confidence intervals. Values between 1000 and 10000 are
3110
+ recommended.
3111
+
3112
+ usermedians : array-like, optional
3113
+ An array or sequence whose first dimension (or length) is
3114
+ compatible with ``x``. This overrides the medians computed
3115
+ by matplotlib for each element of ``usermedians`` that is not
3116
+ `None`. When an element of ``usermedians`` is None, the median
3117
+ will be computed by matplotlib as normal.
3118
+
3119
+ conf_intervals : array-like, optional
3120
+ Array or sequence whose first dimension (or length) is
3121
+ compatible with ``x`` and whose second dimension is 2. When
3122
+ the an element of ``conf_intervals`` is not None, the
3123
+ notch locations computed by matplotlib are overridden
3124
+ (provided ``notch`` is `True`). When an element of
3125
+ ``conf_intervals`` is `None`, the notches are computed by the
3126
+ method specified by the other kwargs (e.g., ``bootstrap``).
3127
+
3128
+ positions : array-like, optional
3129
+ Sets the positions of the boxes. The ticks and limits are
3130
+ automatically set to match the positions. Defaults to
3131
+ `range(1, N+1)` where N is the number of boxes to be drawn.
3132
+
3133
+ widths : scalar or array-like
3134
+ Sets the width of each box either with a scalar or a
3135
+ sequence. The default is 0.5, or ``0.15*(distance between
3136
+ extreme positions)``, if that is smaller.
3137
+
3138
+ patch_artist : bool, optional (False)
3139
+ If `False` produces boxes with the Line2D artist. Otherwise,
3140
+ boxes and drawn with Patch artists.
3141
+
3142
+ labels : sequence, optional
3143
+ Labels for each dataset. Length must be compatible with
3144
+ dimensions of ``x``.
3145
+
3146
+ manage_xticks : bool, optional (True)
3147
+ If the function should adjust the xlim and xtick locations.
3159
3148
3160
- capprops : dict or None (default)
3161
- If provided, will set the plotting style of the caps
3149
+ autorange : bool, optional (False)
3150
+ When `True` and the data are distributed such that the 25th and
3151
+ 75th percentiles are equal, ``whis`` is set to ``'range'`` such
3152
+ that the whisker ends are at the minimum and maximum of the
3153
+ data.
3154
+
3155
+ meanline : bool, optional (False)
3156
+ If `True` (and ``showmeans`` is `True`), will try to render
3157
+ the mean as a line spanning the full width of the box
3158
+ according to ``meanprops`` (see below). Not recommended if
3159
+ ``shownotches`` is also True. Otherwise, means will be shown
3160
+ as points.
3161
+
3162
+ Additional Options
3163
+ ---------------------
3164
+ The following boolean options toggle the drawing of individual
3165
+ components of the boxplots:
3166
+ - showcaps: the caps on the ends of whiskers
3167
+ (default is True)
3168
+ - showbox: the central box (default is True)
3169
+ - showfliers: the outliers beyond the caps (default is True)
3170
+ - showmeans: the arithmetic means (default is False)
3171
+
3172
+ The remaining options can accept dictionaries that specify the
3173
+ style of the individual artists:
3174
+ - capprops
3175
+ - boxprops
3176
+ - whiskerprops
3177
+ - flierprops
3178
+ - medianprops
3179
+ - meanprops
3162
3180
3163
- flierprops : dict or None (default)
3164
- If provided, will set the plotting style of the fliers
3181
+ Returns
3182
+ -------
3183
+ result : dict
3184
+ A dictionary mapping each component of the boxplot to a list
3185
+ of the :class:`matplotlib.lines.Line2D` instances
3186
+ created. That dictionary has the following keys (assuming
3187
+ vertical boxplots):
3165
3188
3166
- medianprops : dict or None (default)
3167
- If provided, will set the plotting style of the medians
3189
+ - ``boxes``: the main body of the boxplot showing the
3190
+ quartiles and the median's confidence intervals if
3191
+ enabled.
3168
3192
3169
- meanprops : dict or None (default)
3170
- If provided, will set the plotting style of the means
3193
+ - ``medians``: horizontal lines at the median of each box.
3171
3194
3172
- meanline : bool, default = False
3173
- If True (and *showmeans* is True), will try to render the mean
3174
- as a line spanning the full width of the box according to
3175
- *meanprops*. Not recommended if *shownotches* is also True.
3176
- Otherwise, means will be shown as points.
3195
+ - ``whiskers``: the vertical lines extending to the most
3196
+ extreme, non-outlier data points.
3177
3197
3178
- manage_xticks : bool, default = True
3179
- If the function should adjust the xlim and xtick locations .
3198
+ - ``caps``: the horizontal lines at the ends of the
3199
+ whiskers .
3180
3200
3181
- Returns
3182
- -------
3201
+ - ``fliers``: points representing data that extend beyond
3202
+ the whiskers (fliers).
3183
3203
3184
- result : dict
3185
- A dictionary mapping each component of the boxplot
3186
- to a list of the :class:`matplotlib.lines.Line2D`
3187
- instances created. That dictionary has the following keys
3188
- (assuming vertical boxplots):
3189
-
3190
- - boxes: the main body of the boxplot showing the quartiles
3191
- and the median's confidence intervals if enabled.
3192
- - medians: horizonal lines at the median of each box.
3193
- - whiskers: the vertical lines extending to the most extreme,
3194
- n-outlier data points.
3195
- - caps: the horizontal lines at the ends of the whiskers.
3196
- - fliers: points representing data that extend beyond the
3197
- whiskers (outliers).
3198
- - means: points or lines representing the means.
3204
+ - ``means``: points or lines representing the means.
3199
3205
3200
3206
Examples
3201
3207
--------
3202
-
3203
3208
.. plot:: mpl_examples/statistics/boxplot_demo.py
3209
+
3204
3210
"""
3211
+
3205
3212
# If defined in matplotlibrc, apply the value from rc file
3206
3213
# Overridden if argument is passed
3207
3214
if whis is None :
3208
3215
whis = rcParams ['boxplot.whiskers' ]
3209
3216
if bootstrap is None :
3210
3217
bootstrap = rcParams ['boxplot.bootstrap' ]
3211
3218
bxpstats = cbook .boxplot_stats (x , whis = whis , bootstrap = bootstrap ,
3212
- labels = labels )
3219
+ labels = labels , autorange = autorange )
3213
3220
if notch is None :
3214
3221
notch = rcParams ['boxplot.notch' ]
3215
3222
if vert is None :
@@ -3455,10 +3462,10 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
3455
3462
quartiles and the median's confidence intervals if
3456
3463
enabled.
3457
3464
3458
- - ``medians``: horizonal lines at the median of each box.
3465
+ - ``medians``: horizontal lines at the median of each box.
3459
3466
3460
3467
- ``whiskers``: the vertical lines extending to the most
3461
- extreme, n -outlier data points.
3468
+ extreme, non -outlier data points.
3462
3469
3463
3470
- ``caps``: the horizontal lines at the ends of the
3464
3471
whiskers.
0 commit comments