@@ -3439,10 +3439,11 @@ def _upcast_err(err):
34393439 eb_cap_style ['color' ] = ecolor
34403440
34413441 barcols = []
3442- caplines = []
3442+ caplines = { 'x' : [], 'y' : []}
34433443
34443444 # Vectorized fancy-indexer.
3445- def apply_mask (arrays , mask ): return [array [mask ] for array in arrays ]
3445+ def apply_mask (arrays , mask ):
3446+ return [array [mask ] for array in arrays ]
34463447
34473448 # dep: dependent dataset, indep: independent dataset
34483449 for (dep_axis , dep , err , lolims , uplims , indep , lines_func ,
@@ -3486,7 +3487,7 @@ def apply_mask(arrays, mask): return [array[mask] for array in arrays]
34863487 line = mlines .Line2D (indep_masked , indep_masked ,
34873488 marker = marker , ** eb_cap_style )
34883489 line .set (** {f"{ dep_axis } data" : lh_masked })
3489- caplines .append (line )
3490+ caplines [ dep_axis ] .append (line )
34903491 for idx , (lims , hl ) in enumerate ([(lolims , high ), (uplims , low )]):
34913492 if not lims .any ():
34923493 continue
@@ -3500,15 +3501,28 @@ def apply_mask(arrays, mask): return [array[mask] for array in arrays]
35003501 line = mlines .Line2D (x_masked , y_masked ,
35013502 marker = hlmarker , ** eb_cap_style )
35023503 line .set (** {f"{ dep_axis } data" : hl_masked })
3503- caplines .append (line )
3504+ caplines [ dep_axis ] .append (line )
35043505 if capsize > 0 :
3505- caplines .append (mlines .Line2D (
3506+ caplines [ dep_axis ] .append (mlines .Line2D (
35063507 x_masked , y_masked , marker = marker , ** eb_cap_style ))
35073508
3508- for l in caplines :
3509- self .add_line (l )
3509+ for axis in caplines :
3510+ for l in caplines [axis ]:
3511+ if self .name == 'polar' :
3512+ # Rotate caps to be perpendicular to the error bars
3513+ for theta , r in zip (l .get_xdata (), l .get_ydata ()):
3514+ rotation = theta
3515+ if axis == 'x' :
3516+ rotation += np .pi / 2
3517+ ms = mmarkers .MarkerStyle (marker = marker )
3518+ ms ._transform = mtransforms .Affine2D ().rotate (rotation )
3519+ self .add_line (mlines .Line2D ([theta ], [r ], marker = ms ,
3520+ ** eb_cap_style ))
3521+ else :
3522+ self .add_line (l )
35103523
35113524 self ._request_autoscale_view ()
3525+ caplines = caplines ['x' ] + caplines ['y' ]
35123526 errorbar_container = ErrorbarContainer (
35133527 (data_line , tuple (caplines ), tuple (barcols )),
35143528 has_xerr = (xerr is not None ), has_yerr = (yerr is not None ),
0 commit comments