@@ -3201,6 +3201,38 @@ def get_next_color():
32013201 else :
32023202 return slices , texts , autotexts
32033203
3204+ @staticmethod
3205+ def _errorevery_to_mask (x , errorevery ):
3206+ """
3207+ Normalize `errorbar`'s *errorevery* to be a boolean mask for data *x*.
3208+
3209+ This function is split out to be usable both by 2D and 3D errorbars.
3210+ """
3211+ if isinstance (errorevery , Integral ):
3212+ errorevery = (0 , errorevery )
3213+ if isinstance (errorevery , tuple ):
3214+ if (len (errorevery ) == 2 and
3215+ isinstance (errorevery [0 ], Integral ) and
3216+ isinstance (errorevery [1 ], Integral )):
3217+ errorevery = slice (errorevery [0 ], None , errorevery [1 ])
3218+ else :
3219+ raise ValueError (
3220+ f'{ errorevery = !r} is a not a tuple of two integers' )
3221+ elif isinstance (errorevery , slice ):
3222+ pass
3223+ elif not isinstance (errorevery , str ) and np .iterable (errorevery ):
3224+ try :
3225+ x [errorevery ] # fancy indexing
3226+ except (ValueError , IndexError ) as err :
3227+ raise ValueError (
3228+ f"{ errorevery = !r} is iterable but not a valid NumPy fancy "
3229+ "index to match 'xerr'/'yerr'" ) from err
3230+ else :
3231+ raise ValueError (f"{ errorevery = !r} is not a recognized value" )
3232+ everymask = np .zeros (len (x ), bool )
3233+ everymask [errorevery ] = True
3234+ return everymask
3235+
32043236 @_preprocess_data (replace_names = ["x" , "y" , "xerr" , "yerr" ],
32053237 label_namer = "y" )
32063238 @_docstring .dedent_interpd
@@ -3375,32 +3407,7 @@ def _upcast_err(err):
33753407 if len (x ) != len (y ):
33763408 raise ValueError ("'x' and 'y' must have the same size" )
33773409
3378- if isinstance (errorevery , Integral ):
3379- errorevery = (0 , errorevery )
3380- if isinstance (errorevery , tuple ):
3381- if (len (errorevery ) == 2 and
3382- isinstance (errorevery [0 ], Integral ) and
3383- isinstance (errorevery [1 ], Integral )):
3384- errorevery = slice (errorevery [0 ], None , errorevery [1 ])
3385- else :
3386- raise ValueError (
3387- f'errorevery={ errorevery !r} is a not a tuple of two '
3388- f'integers' )
3389- elif isinstance (errorevery , slice ):
3390- pass
3391- elif not isinstance (errorevery , str ) and np .iterable (errorevery ):
3392- # fancy indexing
3393- try :
3394- x [errorevery ]
3395- except (ValueError , IndexError ) as err :
3396- raise ValueError (
3397- f"errorevery={ errorevery !r} is iterable but not a valid "
3398- f"NumPy fancy index to match 'xerr'/'yerr'" ) from err
3399- else :
3400- raise ValueError (
3401- f"errorevery={ errorevery !r} is not a recognized value" )
3402- everymask = np .zeros (len (x ), bool )
3403- everymask [errorevery ] = True
3410+ everymask = self ._errorevery_to_mask (x , errorevery )
34043411
34053412 label = kwargs .pop ("label" , None )
34063413 kwargs ['label' ] = '_nolegend_'
0 commit comments