@@ -3315,35 +3315,8 @@ def errorbar(self, x, y, yerr=None, xerr=None,
33153315
33163316 self ._process_unit_info (xdata = x , ydata = y , kwargs = kwargs )
33173317
3318- plot_line = (fmt .lower () != 'none' )
3319- label = kwargs .pop ("label" , None )
3320-
3321- if fmt == '' :
3322- fmt_style_kwargs = {}
3323- else :
3324- fmt_style_kwargs = {k : v for k , v in
3325- zip (('linestyle' , 'marker' , 'color' ),
3326- _process_plot_format (fmt ))
3327- if v is not None }
3328- if fmt == 'none' :
3329- # Remove alpha=0 color that _process_plot_format returns
3330- fmt_style_kwargs .pop ('color' )
3331-
3332- if ('color' in kwargs or 'color' in fmt_style_kwargs ):
3333- base_style = {}
3334- if 'color' in kwargs :
3335- base_style ['color' ] = kwargs .pop ('color' )
3336- else :
3337- base_style = next (self ._get_lines .prop_cycler )
3338-
3339- base_style ['label' ] = '_nolegend_'
3340- base_style .update (fmt_style_kwargs )
3341- if 'color' not in base_style :
3342- base_style ['color' ] = 'C0'
3343- if ecolor is None :
3344- ecolor = base_style ['color' ]
3345- # make sure all the args are iterable; use lists not arrays to
3346- # preserve units
3318+ # Make sure all the args are iterable; use lists not arrays to preserve
3319+ # units.
33473320 if not np .iterable (x ):
33483321 x = [x ]
33493322
@@ -3361,19 +3334,50 @@ def errorbar(self, x, y, yerr=None, xerr=None,
33613334 if not np .iterable (yerr ):
33623335 yerr = [yerr ] * len (y )
33633336
3364- # make the style dict for the 'normal' plot line
3365- plot_line_style = {
3366- ** base_style ,
3367- ** kwargs ,
3368- 'zorder' : (kwargs ['zorder' ] - .1 if barsabove else
3369- kwargs ['zorder' ] + .1 ),
3370- }
3337+ label = kwargs .pop ("label" , None )
3338+ kwargs ['label' ] = '_nolegend_'
3339+
3340+ # Create the main line and determine overall kwargs for child artists.
3341+ # We avoid calling self.plot() directly, or self._get_lines(), because
3342+ # that would call self._process_unit_info again, and do other indirect
3343+ # data processing.
3344+ (data_line , base_style ), = self ._get_lines ._plot_args (
3345+ (x , y ) if fmt == '' else (x , y , fmt ), kwargs , return_kwargs = True )
3346+
3347+ # Do this after creating `data_line` to avoid modifying `base_style`.
3348+ if barsabove :
3349+ data_line .set_zorder (kwargs ['zorder' ] - .1 )
3350+ else :
3351+ data_line .set_zorder (kwargs ['zorder' ] + .1 )
3352+
3353+ # Add line to plot, or throw it away and use it to determine kwargs.
3354+ if fmt .lower () != 'none' :
3355+ self .add_line (data_line )
3356+ else :
3357+ data_line = None
3358+ # Remove alpha=0 color that _get_lines._plot_args returns for
3359+ # 'none' format, and replace it with user-specified color, if
3360+ # supplied.
3361+ base_style .pop ('color' )
3362+ if 'color' in kwargs :
3363+ base_style ['color' ] = kwargs .pop ('color' )
3364+
3365+ if 'color' not in base_style :
3366+ base_style ['color' ] = 'C0'
3367+ if ecolor is None :
3368+ ecolor = base_style ['color' ]
33713369
3372- # make the style dict for the line collections (the bars)
3373- eb_lines_style = dict (base_style )
3374- eb_lines_style .pop ('marker' , None )
3375- eb_lines_style .pop ('linestyle' , None )
3376- eb_lines_style ['color' ] = ecolor
3370+ # Eject any marker information from line format string, as it's not
3371+ # needed for bars or caps.
3372+ base_style .pop ('marker' , None )
3373+ base_style .pop ('markersize' , None )
3374+ base_style .pop ('markerfacecolor' , None )
3375+ base_style .pop ('markeredgewidth' , None )
3376+ base_style .pop ('markeredgecolor' , None )
3377+ base_style .pop ('linestyle' , None )
3378+
3379+ # Make the style dict for the line collections (the bars).
3380+ eb_lines_style = {** base_style , 'color' : ecolor }
33773381
33783382 if elinewidth :
33793383 eb_lines_style ['linewidth' ] = elinewidth
@@ -3384,15 +3388,8 @@ def errorbar(self, x, y, yerr=None, xerr=None,
33843388 if key in kwargs :
33853389 eb_lines_style [key ] = kwargs [key ]
33863390
3387- # set up cap style dictionary
3388- eb_cap_style = dict (base_style )
3389- # eject any marker information from format string
3390- eb_cap_style .pop ('marker' , None )
3391- eb_lines_style .pop ('markerfacecolor' , None )
3392- eb_lines_style .pop ('markeredgewidth' , None )
3393- eb_lines_style .pop ('markeredgecolor' , None )
3394- eb_cap_style .pop ('ls' , None )
3395- eb_cap_style ['linestyle' ] = 'none'
3391+ # Make the style dict for the caps.
3392+ eb_cap_style = {** base_style , 'linestyle' : 'none' }
33963393 if capsize is None :
33973394 capsize = rcParams ["errorbar.capsize" ]
33983395 if capsize > 0 :
@@ -3408,11 +3405,6 @@ def errorbar(self, x, y, yerr=None, xerr=None,
34083405 eb_cap_style [key ] = kwargs [key ]
34093406 eb_cap_style ['color' ] = ecolor
34103407
3411- data_line = None
3412- if plot_line :
3413- data_line = mlines .Line2D (x , y , ** plot_line_style )
3414- self .add_line (data_line )
3415-
34163408 barcols = []
34173409 caplines = []
34183410
0 commit comments