Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ec4d9aa

Browse files
QuLogicMihaiAnton
authored andcommitted
Make errorbar3d property cycling match 2D.
As with 2D before matplotlib#17930, it would not cycle if a color were specified. However, this does not match `plot`, which does not advance the cycle only if _all_ properties in the cycle are specified. Notably, this means if your property cycle was for line style, specifying a color would ignore the cycle in `errorbar`, but not in `plot`. This is a 3D version of 149e7fb and 0782c74.
1 parent 2490d2b commit ec4d9aa

1 file changed

Lines changed: 21 additions & 33 deletions

File tree

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3154,43 +3154,36 @@ def errorbar(self, x, y, z, zerr=None, yerr=None, xerr=None, fmt='',
31543154
if not len(x) == len(y) == len(z):
31553155
raise ValueError("'x', 'y', and 'z' must have the same size")
31563156

3157-
plot_line = (fmt.lower() != 'none')
31583157
label = kwargs.pop("label", None)
3159-
3160-
if fmt == '':
3161-
fmt_style_kwargs = {}
3158+
kwargs['label'] = '_nolegend_'
3159+
3160+
# Create the main line and determine overall kwargs for child artists.
3161+
# We avoid calling self.plot() directly, or self._get_lines(), because
3162+
# that would call self._process_unit_info again, and do other indirect
3163+
# data processing.
3164+
(data_line, base_style), = self._get_lines._plot_args(
3165+
(x, y) if fmt == '' else (x, y, fmt), kwargs, return_kwargs=True)
3166+
art3d.line_2d_to_3d(data_line, zs=z)
3167+
3168+
# Do this after creating `data_line` to avoid modifying `base_style`.
3169+
if barsabove:
3170+
data_line.set_zorder(kwargs['zorder'] - .1)
31623171
else:
3163-
fmt_style_kwargs = {k: v for k, v in
3164-
zip(('linestyle', 'marker', 'color'),
3165-
_process_plot_format(fmt))
3166-
if v is not None}
3167-
3168-
if fmt == 'none':
3169-
# Remove alpha=0 color that _process_plot_format returns
3170-
fmt_style_kwargs.pop('color')
3171-
3172-
if ('color' in kwargs or 'color' in fmt_style_kwargs):
3173-
base_style = {}
3174-
if 'color' in kwargs:
3175-
base_style['color'] = kwargs.pop('color')
3172+
data_line.set_zorder(kwargs['zorder'] + .1)
3173+
3174+
# Add line to plot, or throw it away and use it to determine kwargs.
3175+
if fmt.lower() != 'none':
3176+
self.add_line(data_line)
31763177
else:
3177-
base_style = next(self._get_lines.prop_cycler)
3178+
data_line = None
3179+
# Remove alpha=0 color that _process_plot_format returns.
3180+
base_style.pop('color')
31783181

3179-
base_style['label'] = '_nolegend_'
3180-
base_style.update(fmt_style_kwargs)
31813182
if 'color' not in base_style:
31823183
base_style['color'] = 'C0'
31833184
if ecolor is None:
31843185
ecolor = base_style['color']
31853186

3186-
# make the style dict for the 'normal' plot line
3187-
plot_line_style = {
3188-
**base_style,
3189-
**kwargs,
3190-
'zorder': (kwargs['zorder'] - .1 if barsabove else
3191-
kwargs['zorder'] + .1),
3192-
}
3193-
31943187
# Eject any marker information from line format string, as it's not
31953188
# needed for bars or caps.
31963189
base_style.pop('marker', None)
@@ -3222,11 +3215,6 @@ def errorbar(self, x, y, z, zerr=None, yerr=None, xerr=None, fmt='',
32223215
eb_cap_style['markeredgewidth'] = capthick
32233216
eb_cap_style['color'] = ecolor
32243217

3225-
data_line = None
3226-
if plot_line:
3227-
data_line = art3d.Line3D(x, y, z, **plot_line_style)
3228-
self.add_line(data_line)
3229-
32303218
everymask = np.zeros(len(x), bool)
32313219
everymask[offset::errorevery] = True
32323220

0 commit comments

Comments
 (0)