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

Skip to content

Commit e414df3

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 52e93d1 commit e414df3

File tree

1 file changed

+22
-34
lines changed

1 file changed

+22
-34
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import matplotlib.container as mcontainer
3030
import matplotlib.transforms as mtransforms
3131
from matplotlib.axes import Axes, rcParams
32-
from matplotlib.axes._base import _axis_method_wrapper, _process_plot_format
32+
from matplotlib.axes._base import _axis_method_wrapper
3333
from matplotlib.transforms import Bbox
3434
from matplotlib.tri.triangulation import Triangulation
3535

@@ -3051,43 +3051,36 @@ def errorbar(self, x, y, z, zerr=None, yerr=None, xerr=None, fmt='',
30513051
if not len(x) == len(y) == len(z):
30523052
raise ValueError("'x', 'y', and 'z' must have the same size")
30533053

3054-
plot_line = (fmt.lower() != 'none')
30553054
label = kwargs.pop("label", None)
3056-
3057-
if fmt == '':
3058-
fmt_style_kwargs = {}
3055+
kwargs['label'] = '_nolegend_'
3056+
3057+
# Create the main line and determine overall kwargs for child artists.
3058+
# We avoid calling self.plot() directly, or self._get_lines(), because
3059+
# that would call self._process_unit_info again, and do other indirect
3060+
# data processing.
3061+
(data_line, base_style), = self._get_lines._plot_args(
3062+
(x, y) if fmt == '' else (x, y, fmt), kwargs, return_kwargs=True)
3063+
art3d.line_2d_to_3d(data_line, zs=z)
3064+
3065+
# Do this after creating `data_line` to avoid modifying `base_style`.
3066+
if barsabove:
3067+
data_line.set_zorder(kwargs['zorder'] - .1)
30593068
else:
3060-
fmt_style_kwargs = {k: v for k, v in
3061-
zip(('linestyle', 'marker', 'color'),
3062-
_process_plot_format(fmt))
3063-
if v is not None}
3064-
3065-
if fmt == 'none':
3066-
# Remove alpha=0 color that _process_plot_format returns
3067-
fmt_style_kwargs.pop('color')
3068-
3069-
if ('color' in kwargs or 'color' in fmt_style_kwargs):
3070-
base_style = {}
3071-
if 'color' in kwargs:
3072-
base_style['color'] = kwargs.pop('color')
3069+
data_line.set_zorder(kwargs['zorder'] + .1)
3070+
3071+
# Add line to plot, or throw it away and use it to determine kwargs.
3072+
if fmt.lower() != 'none':
3073+
self.add_line(data_line)
30733074
else:
3074-
base_style = next(self._get_lines.prop_cycler)
3075+
data_line = None
3076+
# Remove alpha=0 color that _process_plot_format returns.
3077+
base_style.pop('color')
30753078

3076-
base_style['label'] = '_nolegend_'
3077-
base_style.update(fmt_style_kwargs)
30783079
if 'color' not in base_style:
30793080
base_style['color'] = 'C0'
30803081
if ecolor is None:
30813082
ecolor = base_style['color']
30823083

3083-
# make the style dict for the 'normal' plot line
3084-
plot_line_style = {
3085-
**base_style,
3086-
**kwargs,
3087-
'zorder': (kwargs['zorder'] - .1 if barsabove else
3088-
kwargs['zorder'] + .1),
3089-
}
3090-
30913084
# Eject any marker information from line format string, as it's not
30923085
# needed for bars or caps.
30933086
base_style.pop('marker', None)
@@ -3119,11 +3112,6 @@ def errorbar(self, x, y, z, zerr=None, yerr=None, xerr=None, fmt='',
31193112
eb_cap_style['markeredgewidth'] = capthick
31203113
eb_cap_style['color'] = ecolor
31213114

3122-
data_line = None
3123-
if plot_line:
3124-
data_line = art3d.Line3D(x, y, z, **plot_line_style)
3125-
self.add_line(data_line)
3126-
31273115
everymask = np.zeros(len(x), bool)
31283116
everymask[offset::errorevery] = True
31293117

0 commit comments

Comments
 (0)