@@ -3433,7 +3433,7 @@ def errorbar(self, x, y, yerr=None, xerr=None,
34333433 eb_cap_style ['color' ] = ecolor
34343434
34353435 barcols = []
3436- caplines = []
3436+ caplines = { 'x' : [], 'y' : []}
34373437
34383438 # Vectorized fancy-indexer.
34393439 def apply_mask (arrays , mask ): return [array [mask ] for array in arrays ]
@@ -3477,7 +3477,7 @@ def apply_mask(arrays, mask): return [array[mask] for array in arrays]
34773477 line = mlines .Line2D (indep_masked , indep_masked ,
34783478 marker = marker , ** eb_cap_style )
34793479 line .set (** {f"{ dep_axis } data" : lh_masked })
3480- caplines .append (line )
3480+ caplines [ dep_axis ] .append (line )
34813481 for idx , (lims , hl ) in enumerate ([(lolims , high ), (uplims , low )]):
34823482 if not lims .any ():
34833483 continue
@@ -3491,13 +3491,25 @@ def apply_mask(arrays, mask): return [array[mask] for array in arrays]
34913491 line = mlines .Line2D (x_masked , y_masked ,
34923492 marker = hlmarker , ** eb_cap_style )
34933493 line .set (** {f"{ dep_axis } data" : hl_masked })
3494- caplines .append (line )
3494+ caplines [ dep_axis ] .append (line )
34953495 if capsize > 0 :
3496- caplines .append (mlines .Line2D (
3496+ caplines [ dep_axis ] .append (mlines .Line2D (
34973497 x_masked , y_masked , marker = marker , ** eb_cap_style ))
34983498
3499- for l in caplines :
3500- self .add_line (l )
3499+ for axis in caplines :
3500+ for l in caplines [axis ]:
3501+ if self .name == 'polar' :
3502+ # Rotate caps to be perpendicular to the error bars
3503+ for theta , r in zip (l .get_xdata (), l .get_ydata ()):
3504+ rotation = theta
3505+ if axis == 'x' :
3506+ rotation += np .pi / 2
3507+ ms = mmarkers .MarkerStyle (marker = marker )
3508+ ms ._transform = mtransforms .Affine2D ().rotate (rotation )
3509+ self .add_line (mlines .Line2D ([theta ], [r ], marker = ms ,
3510+ ** eb_cap_style ))
3511+ else :
3512+ self .add_line (l )
35013513
35023514 self ._request_autoscale_view ()
35033515 errorbar_container = ErrorbarContainer (
0 commit comments