22
22
import matplotlib .axes as maxes
23
23
import matplotlib .collections as mcoll
24
24
import matplotlib .colors as mcolors
25
+ import matplotlib .lines as mlines
25
26
import matplotlib .scale as mscale
26
27
import matplotlib .container as mcontainer
27
28
import matplotlib .transforms as mtransforms
@@ -3101,6 +3102,35 @@ def errorbar(self, x, y, z, zerr=None, yerr=None, xerr=None, fmt='',
3101
3102
"""
3102
3103
had_data = self .has_data ()
3103
3104
3105
+ kwargs = cbook .normalize_kwargs (kwargs , mlines .Line2D )
3106
+ # anything that comes in as 'None', drop so the default thing
3107
+ # happens down stream
3108
+ kwargs = {k : v for k , v in kwargs .items () if v is not None }
3109
+ kwargs .setdefault ('zorder' , 2 )
3110
+
3111
+ try :
3112
+ offset , errorevery = errorevery
3113
+ except TypeError :
3114
+ offset = 0
3115
+
3116
+ if errorevery < 1 or int (errorevery ) != errorevery :
3117
+ raise ValueError (
3118
+ 'errorevery must be positive integer or tuple of integers' )
3119
+ if int (offset ) != offset :
3120
+ raise ValueError ("errorevery's starting index must be an integer" )
3121
+
3122
+ self ._process_unit_info ([("x" , x ), ("y" , y ), ("z" , z )], kwargs ,
3123
+ convert = False )
3124
+
3125
+ # make sure all the args are iterable; use lists not arrays to
3126
+ # preserve units
3127
+ x = x if np .iterable (x ) else [x ]
3128
+ y = y if np .iterable (y ) else [y ]
3129
+ z = z if np .iterable (z ) else [z ]
3130
+
3131
+ if not len (x ) == len (y ) == len (z ):
3132
+ raise ValueError ("'x', 'y', and 'z' must have the same size" )
3133
+
3104
3134
plot_line = (fmt .lower () != 'none' )
3105
3135
label = kwargs .pop ("label" , None )
3106
3136
@@ -3130,33 +3160,25 @@ def errorbar(self, x, y, z, zerr=None, yerr=None, xerr=None, fmt='',
3130
3160
if ecolor is None :
3131
3161
ecolor = base_style ['color' ]
3132
3162
3133
- # make sure all the args are iterable; use lists not arrays to
3134
- # preserve units
3135
- x = x if np .iterable (x ) else [x ]
3136
- y = y if np .iterable (y ) else [y ]
3137
- z = z if np .iterable (z ) else [z ]
3138
-
3139
- if not len (x ) == len (y ) == len (z ):
3140
- raise ValueError ("'x', 'y', and 'z' must have the same size" )
3141
-
3142
3163
# make the style dict for the 'normal' plot line
3143
- if 'zorder' not in kwargs :
3144
- kwargs ['zorder' ] = 2
3145
3164
plot_line_style = {
3146
3165
** base_style ,
3147
3166
** kwargs ,
3148
3167
'zorder' : (kwargs ['zorder' ] - .1 if barsabove else
3149
3168
kwargs ['zorder' ] + .1 ),
3150
3169
}
3151
3170
3152
- # make the style dict for the line collections (the bars)
3153
- eb_lines_style = dict (base_style )
3154
- eb_lines_style .pop ('marker' , None )
3155
- eb_lines_style .pop ('markerfacecolor' , None )
3156
- eb_lines_style .pop ('markeredgewidth' , None )
3157
- eb_lines_style .pop ('markeredgecolor' , None )
3158
- eb_lines_style .pop ('linestyle' , None )
3159
- eb_lines_style ['color' ] = ecolor
3171
+ # Eject any marker information from line format string, as it's not
3172
+ # needed for bars or caps.
3173
+ base_style .pop ('marker' , None )
3174
+ base_style .pop ('markersize' , None )
3175
+ base_style .pop ('markerfacecolor' , None )
3176
+ base_style .pop ('markeredgewidth' , None )
3177
+ base_style .pop ('markeredgecolor' , None )
3178
+ base_style .pop ('linestyle' , None )
3179
+
3180
+ # Make the style dict for the line collections (the bars).
3181
+ eb_lines_style = {** base_style , 'color' : ecolor }
3160
3182
3161
3183
if elinewidth :
3162
3184
eb_lines_style ['linewidth' ] = elinewidth
@@ -3167,35 +3189,21 @@ def errorbar(self, x, y, z, zerr=None, yerr=None, xerr=None, fmt='',
3167
3189
if key in kwargs :
3168
3190
eb_lines_style [key ] = kwargs [key ]
3169
3191
3170
- # make the style dict for cap collections (the "hats")
3171
- eb_cap_style = dict (base_style )
3172
- # eject any marker information from format string
3173
- eb_cap_style .pop ('marker' , None )
3174
- eb_cap_style .pop ('ls' , None )
3175
- eb_cap_style ['linestyle' ] = 'none'
3192
+ # Make the style dict for caps (the "hats").
3193
+ eb_cap_style = {** base_style , 'linestyle' : 'none' }
3176
3194
if capsize is None :
3177
- capsize = kwargs . pop ( 'capsize' , rcParams ["errorbar.capsize" ])
3195
+ capsize = rcParams ["errorbar.capsize" ]
3178
3196
if capsize > 0 :
3179
3197
eb_cap_style ['markersize' ] = 2. * capsize
3180
3198
if capthick is not None :
3181
3199
eb_cap_style ['markeredgewidth' ] = capthick
3182
3200
eb_cap_style ['color' ] = ecolor
3183
3201
3202
+ data_line = None
3184
3203
if plot_line :
3185
3204
data_line = art3d .Line3D (x , y , z , ** plot_line_style )
3186
3205
self .add_line (data_line )
3187
3206
3188
- try :
3189
- offset , errorevery = errorevery
3190
- except TypeError :
3191
- offset = 0
3192
-
3193
- if errorevery < 1 or int (errorevery ) != errorevery :
3194
- raise ValueError (
3195
- 'errorevery must be positive integer or tuple of integers' )
3196
- if int (offset ) != offset :
3197
- raise ValueError ("errorevery's starting index must be an integer" )
3198
-
3199
3207
everymask = np .zeros (len (x ), bool )
3200
3208
everymask [offset ::errorevery ] = True
3201
3209
0 commit comments