@@ -3433,10 +3433,11 @@ def errorbar(self, x, y, yerr=None, xerr=None,
3433
3433
eb_cap_style ['color' ] = ecolor
3434
3434
3435
3435
barcols = []
3436
- caplines = []
3436
+ caplines = { 'x' : [], 'y' : []}
3437
3437
3438
3438
# Vectorized fancy-indexer.
3439
- def apply_mask (arrays , mask ): return [array [mask ] for array in arrays ]
3439
+ def apply_mask (arrays , mask ):
3440
+ return [array [mask ] for array in arrays ]
3440
3441
3441
3442
# dep: dependent dataset, indep: independent dataset
3442
3443
for (dep_axis , dep , err , lolims , uplims , indep , lines_func ,
@@ -3477,7 +3478,7 @@ def apply_mask(arrays, mask): return [array[mask] for array in arrays]
3477
3478
line = mlines .Line2D (indep_masked , indep_masked ,
3478
3479
marker = marker , ** eb_cap_style )
3479
3480
line .set (** {f"{ dep_axis } data" : lh_masked })
3480
- caplines .append (line )
3481
+ caplines [ dep_axis ] .append (line )
3481
3482
for idx , (lims , hl ) in enumerate ([(lolims , high ), (uplims , low )]):
3482
3483
if not lims .any ():
3483
3484
continue
@@ -3491,15 +3492,29 @@ def apply_mask(arrays, mask): return [array[mask] for array in arrays]
3491
3492
line = mlines .Line2D (x_masked , y_masked ,
3492
3493
marker = hlmarker , ** eb_cap_style )
3493
3494
line .set (** {f"{ dep_axis } data" : hl_masked })
3494
- caplines .append (line )
3495
+ caplines [ dep_axis ] .append (line )
3495
3496
if capsize > 0 :
3496
- caplines .append (mlines .Line2D (
3497
+ caplines [ dep_axis ] .append (mlines .Line2D (
3497
3498
x_masked , y_masked , marker = marker , ** eb_cap_style ))
3498
3499
3499
- for l in caplines :
3500
- self .add_line (l )
3500
+ for axis in caplines :
3501
+ for l in caplines [axis ]:
3502
+ if self .name == 'polar' :
3503
+ # Rotate caps to be perpendicular to the error bars
3504
+ for theta , r in zip (l .get_xdata (), l .get_ydata ()):
3505
+ rotation = theta
3506
+ if axis == 'x' :
3507
+ rotation += np .pi / 2
3508
+ ms = mmarkers .MarkerStyle (marker = marker )
3509
+ ms ._transform = mtransforms .Affine2D ().rotate (rotation )
3510
+ self .add_line (mlines .Line2D ([theta ], [r ], marker = ms ,
3511
+ ** eb_cap_style ))
3512
+ else :
3513
+ print (l )
3514
+ self .add_line (l )
3501
3515
3502
3516
self ._request_autoscale_view ()
3517
+ caplines = caplines ['x' ] + caplines ['y' ]
3503
3518
errorbar_container = ErrorbarContainer (
3504
3519
(data_line , tuple (caplines ), tuple (barcols )),
3505
3520
has_xerr = (xerr is not None ), has_yerr = (yerr is not None ),
0 commit comments