@@ -3439,10 +3439,11 @@ def _upcast_err(err):
3439
3439
eb_cap_style ['color' ] = ecolor
3440
3440
3441
3441
barcols = []
3442
- caplines = []
3442
+ caplines = { 'x' : [], 'y' : []}
3443
3443
3444
3444
# 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 ]
3446
3447
3447
3448
# dep: dependent dataset, indep: independent dataset
3448
3449
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]
3486
3487
line = mlines .Line2D (indep_masked , indep_masked ,
3487
3488
marker = marker , ** eb_cap_style )
3488
3489
line .set (** {f"{ dep_axis } data" : lh_masked })
3489
- caplines .append (line )
3490
+ caplines [ dep_axis ] .append (line )
3490
3491
for idx , (lims , hl ) in enumerate ([(lolims , high ), (uplims , low )]):
3491
3492
if not lims .any ():
3492
3493
continue
@@ -3500,15 +3501,28 @@ def apply_mask(arrays, mask): return [array[mask] for array in arrays]
3500
3501
line = mlines .Line2D (x_masked , y_masked ,
3501
3502
marker = hlmarker , ** eb_cap_style )
3502
3503
line .set (** {f"{ dep_axis } data" : hl_masked })
3503
- caplines .append (line )
3504
+ caplines [ dep_axis ] .append (line )
3504
3505
if capsize > 0 :
3505
- caplines .append (mlines .Line2D (
3506
+ caplines [ dep_axis ] .append (mlines .Line2D (
3506
3507
x_masked , y_masked , marker = marker , ** eb_cap_style ))
3507
3508
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 )
3510
3523
3511
3524
self ._request_autoscale_view ()
3525
+ caplines = caplines ['x' ] + caplines ['y' ]
3512
3526
errorbar_container = ErrorbarContainer (
3513
3527
(data_line , tuple (caplines ), tuple (barcols )),
3514
3528
has_xerr = (xerr is not None ), has_yerr = (yerr is not None ),
0 commit comments