@@ -5107,7 +5107,7 @@ def pie(self, x, explode=None, labels=None, colors=None,
5107
5107
def errorbar (self , x , y , yerr = None , xerr = None ,
5108
5108
fmt = '-' , ecolor = None , elinewidth = None , capsize = 3 ,
5109
5109
barsabove = False , lolims = False , uplims = False ,
5110
- xlolims = False , xuplims = False , ** kwargs ):
5110
+ xlolims = False , xuplims = False , errorevery = 1 , ** kwargs ):
5111
5111
"""
5112
5112
call signature::
5113
5113
@@ -5156,6 +5156,10 @@ def errorbar(self, x, y, yerr=None, xerr=None,
5156
5156
only upper/lower limits. In that case a caret symbol is
5157
5157
used to indicate this. lims-arguments may be of the same
5158
5158
type as *xerr* and *yerr*.
5159
+
5160
+ *errorevery*: positive integer
5161
+ subsamples the errorbars. Eg if everyerror=5, errorbars for every
5162
+ 5-th datapoint will be plotted.
5159
5163
5160
5164
All other keyword arguments are passed on to the plot command for the
5161
5165
markers. For example, this code makes big red squares with
@@ -5246,6 +5250,8 @@ def errorbar(self, x, y, yerr=None, xerr=None,
5246
5250
if not iterable (xuplims ): xuplims = np .array ([xuplims ]* len (x ), bool )
5247
5251
else : xuplims = np .asarray (xuplims , bool )
5248
5252
5253
+ everymask = np .arange (len (x )) % errorevery == 0
5254
+
5249
5255
def xywhere (xs , ys , mask ):
5250
5256
"""
5251
5257
return xs[mask], ys[mask] where mask is True but xs and
@@ -5284,33 +5290,38 @@ def xywhere(xs, ys, mask):
5284
5290
right = [thisx + thiserr for (thisx , thiserr )
5285
5291
in cbook .safezip (x ,xerr )]
5286
5292
5287
- barcols .append ( self .hlines (y , left , right , ** lines_kw ) )
5293
+ yo , _ = xywhere (y , right , everymask )
5294
+ lo , ro = xywhere (left , right , everymask )
5295
+ barcols .append ( self .hlines (yo , lo , ro , ** lines_kw ) )
5288
5296
if capsize > 0 :
5289
5297
if xlolims .any ():
5290
5298
# can't use numpy logical indexing since left and
5291
5299
# y are lists
5292
- leftlo , ylo = xywhere (left , y , xlolims )
5300
+ leftlo , ylo = xywhere (left , y , xlolims & everymask )
5293
5301
5294
5302
caplines .extend (
5295
5303
self .plot (leftlo , ylo , ls = 'None' ,
5296
5304
marker = mlines .CARETLEFT , ** plot_kw ) )
5297
5305
xlolims = ~ xlolims
5298
- leftlo , ylo = xywhere (left , y , xlolims )
5306
+ leftlo , ylo = xywhere (left , y , xlolims & everymask )
5299
5307
caplines .extend ( self .plot (leftlo , ylo , 'k|' , ** plot_kw ) )
5300
5308
else :
5301
- caplines .extend ( self .plot (left , y , 'k|' , ** plot_kw ) )
5309
+
5310
+ leftlo , ylo = xywhere (left , y , everymask )
5311
+ caplines .extend ( self .plot (leftlo , ylo , 'k|' , ** plot_kw ) )
5302
5312
5303
5313
if xuplims .any ():
5304
5314
5305
- rightup , yup = xywhere (right , y , xuplims )
5315
+ rightup , yup = xywhere (right , y , xuplims & everymask )
5306
5316
caplines .extend (
5307
5317
self .plot (rightup , yup , ls = 'None' ,
5308
5318
marker = mlines .CARETRIGHT , ** plot_kw ) )
5309
5319
xuplims = ~ xuplims
5310
- rightup , yup = xywhere (right , y , xuplims )
5320
+ rightup , yup = xywhere (right , y , xuplims & everymask )
5311
5321
caplines .extend ( self .plot (rightup , yup , 'k|' , ** plot_kw ) )
5312
5322
else :
5313
- caplines .extend ( self .plot (right , y , 'k|' , ** plot_kw ) )
5323
+ rightup , yup = xywhere (right , y , everymask )
5324
+ caplines .extend ( self .plot (rightup , yup , 'k|' , ** plot_kw ) )
5314
5325
5315
5326
if yerr is not None :
5316
5327
if (iterable (yerr ) and len (yerr )== 2 and
@@ -5327,31 +5338,35 @@ def xywhere(xs, ys, mask):
5327
5338
upper = [thisy + thiserr for (thisy , thiserr )
5328
5339
in cbook .safezip (y ,yerr )]
5329
5340
5330
- barcols .append ( self .vlines (x , lower , upper , ** lines_kw ) )
5341
+ xo , _ = xywhere (x , lower , everymask )
5342
+ lo , uo = xywhere (lower , upper , everymask )
5343
+ barcols .append ( self .vlines (xo , lo , uo , ** lines_kw ) )
5331
5344
if capsize > 0 :
5332
5345
5333
5346
if lolims .any ():
5334
- xlo , lowerlo = xywhere (x , lower , lolims )
5347
+ xlo , lowerlo = xywhere (x , lower , lolims & everymask )
5335
5348
caplines .extend (
5336
5349
self .plot (xlo , lowerlo , ls = 'None' ,
5337
5350
marker = mlines .CARETDOWN , ** plot_kw ) )
5338
5351
lolims = ~ lolims
5339
- xlo , lowerlo = xywhere (x , lower , lolims )
5352
+ xlo , lowerlo = xywhere (x , lower , lolims & everymask )
5340
5353
caplines .extend ( self .plot (xlo , lowerlo , 'k_' , ** plot_kw ) )
5341
5354
else :
5342
- caplines .extend ( self .plot (x , lower , 'k_' , ** plot_kw ) )
5355
+ xlo , lowerlo = xywhere (x , lower , everymask )
5356
+ caplines .extend ( self .plot (xlo , lowerlo , 'k_' , ** plot_kw ) )
5343
5357
5344
5358
if uplims .any ():
5345
- xup , upperup = xywhere (x , upper , uplims )
5359
+ xup , upperup = xywhere (x , upper , uplims & everymask )
5346
5360
5347
5361
caplines .extend (
5348
5362
self .plot (xup , upperup , ls = 'None' ,
5349
5363
marker = mlines .CARETUP , ** plot_kw ) )
5350
5364
uplims = ~ uplims
5351
- xup , upperup = xywhere (x , upper , uplims )
5365
+ xup , upperup = xywhere (x , upper , uplims & everymask )
5352
5366
caplines .extend ( self .plot (xup , upperup , 'k_' , ** plot_kw ) )
5353
5367
else :
5354
- caplines .extend ( self .plot (x , upper , 'k_' , ** plot_kw ) )
5368
+ xup , upperup = xywhere (x , upper , everymask )
5369
+ caplines .extend ( self .plot (xup , upperup , 'k_' , ** plot_kw ) )
5355
5370
5356
5371
if not barsabove and fmt is not None :
5357
5372
l0 , = self .plot (x ,y ,fmt ,** kwargs )
0 commit comments