@@ -2937,7 +2937,7 @@ def boxplot(self, x, notch=False, sym='b+', vert=True, whis=1.5,
2937
2937
2938
2938
# replace medians if necessary:
2939
2939
if usermedians is not None :
2940
- if len (usermedians ) != len (bxpstats ):
2940
+ if len (np . ravel ( usermedians ) ) != len (bxpstats ):
2941
2941
medmsg = 'usermedians length not compatible with x'
2942
2942
raise ValueError (medmsg )
2943
2943
else :
@@ -3100,38 +3100,47 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
3100
3100
'dotted' : ':'
3101
3101
}
3102
3102
3103
- # plotting properties
3104
- if boxprops is None :
3105
- if patch_artist :
3106
- boxprops = dict (linestyle = 'solid' , edgecolor = 'black' ,
3107
- facecolor = 'white' , linewidth = 1 )
3108
- else :
3109
- boxprops = dict (linestyle = '-' , color = 'black' , linewidth = 1 )
3103
+ # box properties
3104
+ if patch_artist :
3105
+ final_boxprops = dict (linestyle = 'solid' , edgecolor = 'black' ,
3106
+ facecolor = 'white' , linewidth = 1 )
3107
+ else :
3108
+ final_boxprops = dict (linestyle = '-' , color = 'black' , linewidth = 1 )
3109
+
3110
+ if boxprops is not None :
3111
+ final_boxprops .update (boxprops )
3110
3112
3113
+ # other (cap, whisker) properties
3111
3114
if patch_artist :
3112
3115
otherprops = dict (
3113
- linestyle = linestyle_map [boxprops ['linestyle' ]],
3114
- color = boxprops ['edgecolor' ],
3115
- linewidth = boxprops .get ('linewidth' , 1 )
3116
+ linestyle = linestyle_map [final_boxprops ['linestyle' ]],
3117
+ color = final_boxprops ['edgecolor' ],
3118
+ linewidth = final_boxprops .get ('linewidth' , 1 )
3116
3119
)
3117
3120
else :
3118
- otherprops = dict (linestyle = boxprops ['linestyle' ],
3119
- color = boxprops ['color' ],
3120
- linewidth = boxprops .get ('linewidth' , 1 ))
3121
-
3122
- if flierprops is None :
3123
- flierprops = dict (linestyle = 'none' , marker = '+' ,
3124
- markeredgecolor = 'blue' )
3125
-
3126
- if medianprops is None :
3127
- medianprops = dict (linestyle = '-' , color = 'blue' )
3128
-
3129
- if meanprops is None :
3130
- if meanline :
3131
- meanprops = dict (linestyle = '--' , color = 'red' )
3132
- else :
3133
- meanprops = dict (linestyle = 'none' , markerfacecolor = 'red' ,
3134
- marker = 's' )
3121
+ otherprops = dict (linestyle = final_boxprops ['linestyle' ],
3122
+ color = final_boxprops ['color' ],
3123
+ linewidth = final_boxprops .get ('linewidth' , 1 ))
3124
+
3125
+ # flier (outlier) properties
3126
+ final_flierprops = dict (linestyle = 'none' , marker = '+' ,
3127
+ markeredgecolor = 'blue' )
3128
+ if flierprops is not None :
3129
+ final_flierprops .update (flierprops )
3130
+
3131
+ # median line properties
3132
+ final_medianprops = dict (linestyle = '-' , color = 'blue' )
3133
+ if medianprops is not None :
3134
+ final_medianprops .update (medianprops )
3135
+
3136
+ # mean (line or point) properties
3137
+ if meanline :
3138
+ final_meanprops = dict (linestyle = '--' , color = 'red' )
3139
+ else :
3140
+ final_meanprops = dict (linestyle = 'none' , markerfacecolor = 'red' ,
3141
+ marker = 's' )
3142
+ if final_meanprops is not None :
3143
+ final_meanprops .update (meanprops )
3135
3144
3136
3145
def to_vc (xs , ys ):
3137
3146
# convert arguments to verts and codes
@@ -3239,54 +3248,37 @@ def dopatch(xs, ys, **kwargs):
3239
3248
# maybe draw the box:
3240
3249
if showbox :
3241
3250
if patch_artist :
3242
- boxes .extend (dopatch (
3243
- box_x , box_y , ** boxprops
3244
- ))
3251
+ boxes .extend (dopatch (box_x , box_y , ** final_boxprops ))
3245
3252
else :
3246
- boxes .extend (doplot (
3247
- box_x , box_y , ** boxprops
3248
- ))
3253
+ boxes .extend (doplot (box_x , box_y , ** final_boxprops ))
3249
3254
3250
3255
# draw the whiskers
3251
- whiskers .extend (doplot (
3252
- whisker_x , whiskerlo_y , ** otherprops
3253
- ))
3254
- whiskers .extend (doplot (
3255
- whisker_x , whiskerhi_y , ** otherprops
3256
- ))
3256
+ whiskers .extend (doplot (whisker_x , whiskerlo_y , ** otherprops ))
3257
+ whiskers .extend (doplot (whisker_x , whiskerhi_y , ** otherprops ))
3257
3258
3258
3259
# maybe draw the caps:
3259
3260
if showcaps :
3260
- caps .extend (doplot (
3261
- cap_x , cap_lo , ** otherprops
3262
- ))
3263
- caps .extend (doplot (
3264
- cap_x , cap_hi , ** otherprops
3265
- ))
3261
+ caps .extend (doplot (cap_x , cap_lo , ** otherprops ))
3262
+ caps .extend (doplot (cap_x , cap_hi , ** otherprops ))
3266
3263
3267
3264
# draw the medians
3268
- medians .extend (doplot (
3269
- med_x , med_y , ** medianprops
3270
- ))
3265
+ medians .extend (doplot (med_x , med_y , ** final_medianprops ))
3271
3266
3272
3267
# maybe draw the means
3273
3268
if showmeans :
3274
3269
if meanline :
3275
3270
means .extend (doplot (
3276
- [box_left , box_right ],
3277
- [stats ['mean' ], stats ['mean' ]],
3278
- ** meanprops
3271
+ [box_left , box_right ], [stats ['mean' ], stats ['mean' ]],
3272
+ ** final_meanprops
3279
3273
))
3280
3274
else :
3281
3275
means .extend (doplot (
3282
- [pos ], [stats ['mean' ]], ** meanprops
3276
+ [pos ], [stats ['mean' ]], ** final_meanprops
3283
3277
))
3284
3278
3285
3279
# maybe draw the fliers
3286
3280
if showfliers :
3287
- fliers .extend (doplot (
3288
- flier_x , flier_y , ** flierprops
3289
- ))
3281
+ fliers .extend (doplot (flier_x
CB62
, flier_y , ** final_flierprops ))
3290
3282
3291
3283
# fix our axes/ticks up a little
3292
3284
if vert :
0 commit comments