@@ -2878,6 +2878,7 @@ def boxplot(self, x, notch=False, sym='b+', vert=True, whis=1.5,
28782878 - caps: the horizontal lines at the ends of the whiskers.
28792879 - fliers: points representing data that extend beyone the
28802880 whiskers (outliers).
2881+ - means: points or lines representing the means.
28812882
28822883 **Example:**
28832884
@@ -2927,11 +2928,121 @@ def boxplot(self, x, notch=False, sym='b+', vert=True, whis=1.5,
29272928
29282929 def bxp (self , bxpstats , positions = None , widths = None , vert = True ,
29292930 patch_artist = False , shownotches = False , showmeans = False ,
2930- showcaps = True , showbox = True , boxprops = None , flierprops = None ,
2931- medianprops = None , meanprops = None , meanline = False ):
2931+ showcaps = True , showbox = True , showfliers = True ,
2932+ boxprops = None , flierprops = None , medianprops = None ,
2933+ meanprops = None , meanline = False ):
2934+ """
2935+ Drawing function for box and whisker plots.
2936+
2937+ Call signature::
2938+
2939+ bxp(self, bxpstats, positions=None, widths=None, vert=True,
2940+ patch_artist=False, shownotches=False, showmeans=False,
2941+ showcaps=True, showbox=True, boxprops=None, flierprops=None,
2942+ medianprops=None, meanprops=None, meanline=False):
2943+
2944+ Make a box and whisker plot for each column of *x* or each
2945+ vector in sequence *x*. The box extends from the lower to
2946+ upper quartile values of the data, with a line at the median.
2947+ The whiskers extend from the box to show the range of the
2948+ data. Flier points are those past the end of the whiskers.
2949+
2950+ Function Arguments:
2951+
2952+ *bxpstats* :
2953+ A list of dictionaries containing stats for each boxplot.
2954+ Required keys are:
2955+ 'med' - The median (scalar float).
2956+ 'q1' - The first quartile (25th percentile) (scalar float).
2957+ 'q3' - The first quartile (50th percentile) (scalar float).
2958+ 'whislo' - Lower bound of the lower whisker (scalar float).
2959+ 'whishi' - Upper bound of the upper whisker (scalar float).
2960+ Optional keys are
2961+ 'mean' - The mean (scalar float). Needed if showmeans=True.
2962+ 'fliers' - Data beyond the whiskers (sequence of floats).
2963+ Needed if showfliers=True.
2964+ 'cilo' & 'ciho' - Lower and upper confidence intervals about
2965+ the median. Needed if shownotches=True.
2966+ 'label' - Name of the dataset (string). If available, this
2967+ will be used a tick label for the boxplot
2968+
2969+ *positions* : [ default 1,2,...,n ]
2970+ Sets the horizontal positions of the boxes. The ticks and limits
2971+ are automatically set to match the positions.
2972+
2973+ *widths* : [ default 0.5 ]
2974+ Either a scalar or a vector and sets the width of each box. The
2975+ default is 0.5, or ``0.15*(distance between extreme positions)``
2976+ if that is smaller.
2977+
2978+ *vert* : [ False | True (default) ]
2979+ If True (default), makes the boxes vertical.
2980+ If False, makes horizontal boxes.
2981+
2982+ *patch_artist* : [ False (default) | True ]
2983+ If False produces boxes with the Line2D artist
2984+ If True produces boxes with the Patch artist1
2985+
2986+ *shownotches* : [ False (default) | True ]
2987+ If False (default), produces a rectangular box plot.
2988+ If True, will produce a notched box plot
2989+
2990+ *showmeans* : [ False (default) | True ]
2991+ If True, will toggle one the rendering of the means
2992+
2993+ *showcaps* : [ False | True (default) ]
2994+ If True, will toggle one the rendering of the caps
2995+
2996+ *showbox* : [ False | True (default) ]
2997+ If True, will toggle one the rendering of box
2998+
2999+ *showfliers* : [ False | True (default) ]
3000+ If True, will toggle one the rendering of the fliers
3001+
3002+ *boxprops* : [ dict | None (default) ]
3003+ If provided, will set the plotting style of the boxes
3004+
3005+ *flierprops* : [ dict | None (default) ]
3006+ If provided, will set the plotting style of the fliers
3007+
3008+ *medianprops* : [ dict | None (default) ]
3009+ If provided, will set the plotting style of the medians
3010+
3011+ *meanprops* : [ dict | None (default) ]
3012+ If provided, will set the plotting style of the means
3013+
3014+ *meanline* : [ False (default) | True ]
3015+ If True (and *showmeans* is True), will try to render the mean
3016+ as a line spanning the full width of the box according to
3017+ *meanprops*. Not recommended if *shownotches* is also True.
3018+ Otherwise, means will be shown as points.
3019+
3020+ Returns a dictionary mapping each component of the boxplot
3021+ to a list of the :class:`matplotlib.lines.Line2D`
3022+ instances created. That dictionary has the following keys
3023+ (assuming vertical boxplots):
29323024
3025+ - boxes: the main body of the boxplot showing the quartiles
3026+ and the median's confidence intervals if enabled.
3027+ - medians: horizonal lines at the median of each box.
3028+ - whiskers: the vertical lines extending to the most extreme,
3029+ n-outlier data points.
3030+ - caps: the horizontal lines at the ends of the whiskers.
3031+ - fliers: points representing data that extend beyone the
3032+ whiskers (fliers).
3033+ - means: points or lines representing the means.
3034+
3035+ **Example:**
3036+
3037+ .. plot:: pyplots/boxplot_demo.py
3038+ """
29333039 # lists of artists to be output
2934- whiskers , caps , boxes , medians , means , fliers = [], [], [], [], [], []
3040+ whiskers = []
3041+ caps = []
3042+ boxes = []
3043+ medians = []
3044+ means = []
3045+ fliers = []
29353046
29363047 # empty list of xticklabels
29373048 datalabels = []
@@ -3039,9 +3150,9 @@ def dopatch(xs, ys, **kwargs):
30393150 # try to find a new label
30403151 datalabels .append (stats .get ('label' , pos ))
30413152
3042- # outliers coords
3043- flier_x = np .ones (len (stats ['outliers ' ])) * pos
3044- flier_y = stats ['outliers ' ]
3153+ # fliers coords
3154+ flier_x = np .ones (len (stats ['fliers ' ])) * pos
3155+ flier_y = stats ['fliers ' ]
30453156
30463157 # whisker coords
30473158 whisker_x = np .ones (2 ) * pos
@@ -3124,10 +3235,11 @@ def dopatch(xs, ys, **kwargs):
31243235 [pos ], [stats ['mean' ]], ** meanprops
31253236 ))
31263237
3127- # draw the outliers
3128- fliers .extend (doplot (
3129- flier_x , flier_y , ** flierprops
3130- ))
3238+ # maybe draw the fliers
3239+ if showfliers :
3240+ fliers .extend (doplot (
3241+ flier_x , flier_y , ** flierprops
3242+ ))
31313243
31323244 # fix our axes/ticks up a little
31333245 if vert :
0 commit comments