@@ -62,19 +62,15 @@ def set_axis_style(ax, labels):
62
62
quartile1 , medians , quartile3 = np .percentile (data , [25 , 50 , 75 ], axis = 1 )
63
63
inter_quartile_ranges = np .vstack ([quartile1 , quartile3 ]).T
64
64
whiskers = [
65
- adjacent_values (sorted_array , q1 , q3 )
65
+ adjacent_values (sorted_array , q1 , q3 )
66
66
for sorted_array , q1 , q3 in zip (data , quartile1 , quartile3 )]
67
-
68
- # plot whiskers as thin lines, quartiles as fat lines,
69
- # and medians as points
70
- for i , median in enumerate (medians ):
71
- ax2 .plot ([i + 1 , i + 1 ], whiskers [i ], '-' , color = 'black' , linewidth = 1 )
72
- ax2 .plot (
73
- [i + 1 , i + 1 ], inter_quartile_ranges [i ], '-' , color = 'black' ,
74
- linewidth = 5 )
75
- ax2 .plot (
76
- i + 1 , median , 'o' , color = 'white' ,
77
- markersize = 6 , markeredgecolor = 'none' )
67
+ whiskersMin , whiskersMax = list (zip (* whiskers ))
68
+ # plot medians as points,
69
+ # whiskers as thin lines, quartiles as fat lines
70
+ inds = np .arange (1 , len (medians ) + 1 )
71
+ ax2 .scatter (inds , medians , marker = 'o' , color = 'white' , s = 30 , zorder = 3 )
72
+ ax2 .vlines (inds , quartile1 , quartile3 , color = 'k' , linestyle = '-' , lw = 5 )
73
+ ax2 .vlines (inds , whiskersMin , whiskersMax , color = 'k' , linestyle = '-' , lw = 1 )
78
74
79
75
# set style for the axes
80
76
labels = ['A' , 'B' , 'C' , 'D' ] # labels
0 commit comments