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