@@ -1039,20 +1039,25 @@ def boxplot_stats(X, whis=1.5, bootstrap=None, labels=None,
10391039 Data that will be represented in the boxplots. Should have 2 or
10401040 fewer dimensions.
10411041
1042- whis : float, string, or sequence (default = 1.5)
1043- As a float, determines the reach of the whiskers beyond the
1044- first and third quartiles. In other words, where IQR is the
1045- interquartile range (`Q3-Q1`), the upper whisker will extend to last
1046- datum less than `Q3 + whis*IQR`. Similarly, the lower whisker will
1047- extend to the first datum greater than `Q1 - whis*IQR`.
1048- Beyond the whiskers, data are considered outliers
1049- and are plotted as individual points. This can be set to an
1050- ascending sequence of percentiles (e.g., [5, 95]) to set the
1051- whiskers at specific percentiles of the data. Finally, `whis`
1052- can be the string ``'range'`` to force the whiskers to the
1053- minimum and maximum of the data. In the edge case that the 25th
1054- and 75th percentiles are equivalent, `whis` can be automatically
1055- set to ``'range'`` via the `autorange` option.
1042+ whis : float or (float, float) (default = 1.5)
1043+ The position of the whiskers.
1044+
1045+ If a float, the lower whisker is at the lowest datum above
1046+ ``Q1 - whis*(Q3-Q1)``, and the upper whisker at the highest datum below
1047+ ``Q3 + whis*(Q3-Q1)``, where Q1 and Q3 are the first and third
1048+ quartiles. The default value of ``whis = 1.5`` corresponds to Tukey's
1049+ original definition of boxplots.
1050+
1051+ If a pair of floats, they indicate the percentiles at which to draw the
1052+ whiskers (e.g., (5, 95)). In particular, setting this to (0, 100)
1053+ results in whiskers covering the whole range of the data. "range" is
1054+ a deprecated synonym for (0, 100).
1055+
1056+ In the edge case where ``Q1 == Q3``, *whis* is automatically set to
1057+ (0, 100) (cover the whole range of the data) if *autorange* is True.
1058+
1059+ Beyond the whiskers, data are considered outliers and are plotted as
1060+ individual points.
10561061
10571062 bootstrap : int, optional
10581063 Number of times the confidence intervals around the median
@@ -1064,7 +1069,7 @@ def boxplot_stats(X, whis=1.5, bootstrap=None, labels=None,
10641069
10651070 autorange : bool, optional (False)
10661071 When `True` and the data are distributed such that the 25th and 75th
1067- percentiles are equal, ``whis`` is set to ``'range'`` such that the
1072+ percentiles are equal, ``whis`` is set to (0, 100) such that the
10681073 whisker ends are at the minimum and maximum of the data.
10691074
10701075 Returns
@@ -1182,7 +1187,7 @@ def _compute_conf_interval(data, med, iqr, bootstrap):
11821187 # interquartile range
11831188 stats ['iqr' ] = q3 - q1
11841189 if stats ['iqr' ] == 0 and autorange :
1185- whis = 'range'
1190+ whis = ( 0 , 100 )
11861191
11871192 # conf. interval around median
11881193 stats ['cilo' ], stats ['cihi' ] = _compute_conf_interval (
@@ -1195,14 +1200,17 @@ def _compute_conf_interval(data, med, iqr, bootstrap):
11951200 loval = q1 - whis * stats ['iqr' ]
11961201 hival = q3 + whis * stats ['iqr' ]
11971202 elif whis in ['range' , 'limit' , 'limits' , 'min/max' ]:
1203+ warn_deprecated (
1204+ "3.2" , message = f"Setting whis to { whis !r} is deprecated "
1205+ "since %(since)s and support for it will be removed "
1206+ "%(removal)s; set it to [0, 100] to achieve the same "
1207+ "effect." )
11981208 loval = np .min (x )
11991209 hival = np .max (x )
12001210 else :
1201- raise ValueError ('whis must be a float, valid string, or list '
1202- 'of percentiles' )
1211+ raise ValueError ('whis must be a float or list of percentiles' )
12031212 else :
1204- loval = np .percentile (x , whis [0 ])
1205- hival = np .percentile (x , whis [1 ])
1213+ loval , hival = np .percentile (x , whis )
12061214
12071215 # get high extreme
12081216 wiskhi = x [x <= hival ]
0 commit comments