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

Skip to content

Commit 6c4844f

Browse files
committed
Make errorbar3d property cycling match 2D.
As with 2D before #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 1614dbb commit 6c4844f

File tree

1 file changed

+21
-33
lines changed

1 file changed

+21
-33
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

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

3134-
plot_line = (fmt.lower() != 'none')
31353134
label = kwargs.pop("label", None)
3136-
3137-
if fmt == '':
3138-
fmt_style_kwargs = {}
3135+
kwargs['label'] = '_nolegend_'
3136+
3137+
# Create the main line and determine overall kwargs for child artists.
3138+
# We avoid calling self.plot() directly, or self._get_lines(), because
3139+
# that would call self._process_unit_info again, and do other indirect
3140+
# data processing.
3141+
(data_line, base_style), = self._get_lines._plot_args(
3142+
(x, y) if fmt == '' else (x, y, fmt), kwargs, return_kwargs=True)
3143+
art3d.line_2d_to_3d(data_line, zs=z)
3144+
3145+
# Do this after creating `data_line` to avoid modifying `base_style`.
3146+
if barsabove:
3147+
data_line.set_zorder(kwargs['zorder'] - .1)
31393148
else:
3140-
fmt_style_kwargs = {k: v for k, v in
3141-
zip(('linestyle', 'marker', 'color'),
3142-
_process_plot_format(fmt))
3143-
if v is not None}
3144-
3145-
if fmt == 'none':
3146-
# Remove alpha=0 color that _process_plot_format returns
3147-
fmt_style_kwargs.pop('color')
3148-
3149-
if ('color' in kwargs or 'color' in fmt_style_kwargs):
3150-
base_style = {}
3151-
if 'color' in kwargs:
3152-
base_style['color'] = kwargs.pop('color')
3149+
data_line.set_zorder(kwargs['zorder'] + .1)
3150+
3151+
# Add line to plot, or throw it away and use it to determine kwargs.
3152+
if fmt.lower() != 'none':
3153+
self.add_line(data_line)
31533154
else:
3154-
base_style = next(self._get_lines.prop_cycler)
3155+
data_line = None
3156+
# Remove alpha=0 color that _process_plot_format returns.
3157+
base_style.pop('color')
31553158

3156-
base_style['label'] = '_nolegend_'
3157-
base_style.update(fmt_style_kwargs)
31583159
if 'color' not in base_style:
31593160
base_style['color'] = 'C0'
31603161
if ecolor is None:
31613162
ecolor = base_style['color']
31623163

3163-
# make the style dict for the 'normal' plot line
3164-
plot_line_style = {
3165-
**base_style,
3166-
**kwargs,
3167-
'zorder': (kwargs['zorder'] - .1 if barsabove else
3168-
kwargs['zorder'] + .1),
3169-
}
3170-
31713164
# Eject any marker information from line format string, as it's not
31723165
# needed for bars or caps.
31733166
base_style.pop('marker', None)
@@ -3199,11 +3192,6 @@ def errorbar(self, x, y, z, zerr=None, yerr=None, xerr=None, fmt='',
31993192
eb_cap_style['markeredgewidth'] = capthick
32003193
eb_cap_style['color'] = ecolor
32013194

3202-
data_line = None
3203-
if plot_line:
3204-
data_line = art3d.Line3D(x, y, z, **plot_line_style)
3205-
self.add_line(data_line)
3206-
32073195
everymask = np.zeros(len(x), bool)
32083196
everymask[offset::errorevery] = True
32093197

0 commit comments

Comments
 (0)