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