@@ -2933,9 +2933,33 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
2933
2933
# lists of artists to be output
2934
2934
whiskers , caps , boxes , medians , means , fliers = [], [], [], [], [], []
2935
2935
2936
+ # empty list of xticklabels
2937
+ datalabels = []
2938
+
2939
+ # translates between line2D and patch linestyles
2940
+ linestyle_map = {
2941
+ 'solid' : '-' ,
2942
+ 'dashed' : '--' ,
2943
+ 'dashdot' : '-.' ,
2944
+ 'dotted' : ':'
2945
+ }
2946
+
2936
2947
# plotting properties
2937
2948
if boxprops is None :
2938
- boxprops = dict (linestyle = '-' , color = 'black' )
2949
+ if patch_artist :
2950
+ boxprops = dict (linestyle = 'solid' , edgecolor = 'black' ,
2951
+ facecolor = 'white' )
2952
+ else :
2953
+ boxprops = dict (linestyle = '-' , color = 'black' )
2954
+
2955
+ if patch_artist :
2956
+ otherprops = dict (
2957
+ linestyle = linestyle_map [boxprops ['linestyle' ]],
2958
+ color = boxprops ['edgecolor' ]
2959
+ )
2960
+ else :
2961
+ otherprops = dict (linestyle = boxprops ['linestyle' ],
2962
+ color = boxprops ['color' ])
2939
2963
2940
2964
if flierprops is None :
2941
2965
flierprops = dict (linestyle = 'none' , marker = '+' ,
@@ -3010,6 +3034,9 @@ def dopatch(xs, ys, **kwargs):
3010
3034
holdStatus = self ._hold
3011
3035
3012
3036
for pos , width , stats in zip (positions , widths , bxpstats ):
3037
+ # try to find a new label
3038
+ datalabels .append (stats .get ('label' , pos ))
3039
+
3013
3040
# outliers coords
3014
3041
flier_x = np .ones (len (stats ['outliers' ])) * pos
3015
3042
flier_y = stats ['outliers' ]
@@ -3061,19 +3088,19 @@ def dopatch(xs, ys, **kwargs):
3061
3088
3062
3089
# draw the whiskers
3063
3090
whiskers .extend (doplot (
3064
- whisker_x , whiskerlo_y , ** boxprops
3091
+ whisker_x , whiskerlo_y , ** otherprops
3065
3092
))
3066
3093
whiskers .extend (doplot (
3067
- whisker_x , whiskerhi_y , ** boxprops
3094
+ whisker_x , whiskerhi_y , ** otherprops
3068
3095
))
3069
3096
3070
3097
# maybe draw the caps:
3071
3098
if showcaps :
3072
3099
caps .extend (doplot (
3073
- cap_x , cap_lo , ** boxprops
3100
+ cap_x , cap_lo , ** otherprops
3074
3101
))
3075
3102
caps .extend (doplot (
3076
- cap_x , cap_hi , ** boxprops
3103
+ cap_x , cap_hi , ** otherprops
3077
3104
))
3078
3105
3079
3106
# draw the medians
@@ -3101,19 +3128,24 @@ def dopatch(xs, ys, **kwargs):
3101
3128
3102
3129
# fix our axes/ticks up a little
3103
3130
if vert :
3104
- setticks , setlim = self .set_xticks , self .set_xlim
3131
+ setticks = self .set_xticks
3132
+ setlim = self .set_xlim
3133
+ setlabels = self .set_xticklabels
3105
3134
else :
3106
- setticks , setlim = self .set_yticks , self .set_ylim
3135
+ setticks = self .set_yticks
3136
+ setlim = self .set_ylim
3137
+ setlabels = self .set_yticklabels
3107
3138
3108
3139
newlimits = min (positions ) - 0.5 , max (positions ) + 0.5
3109
3140
setlim (newlimits )
3110
3141
setticks (positions )
3142
+ setlabels (datalabels )
3111
3143
3112
3144
# reset hold status
3113
3145
self .hold (holdStatus )
3114
3146
3115
3147
return dict (whiskers = whiskers , caps = caps , boxes = boxes ,
3116
- medians = medians , fliers = fliers )
3148
+ medians = medians , fliers = fliers , means = means )
3117
3149
3118
3150
@docstring .dedent_interpd
3119
3151
def scatter (self , x , y , s = 20 , c = 'b' , marker = 'o' , cmap = None , norm = None ,
0 commit comments