Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c548924

Browse filesBrowse files
committed
Make errorbar's main Line2D closer to plot.
We can't directly use `self.plot` or `self._get_lines` because they would do `self._process_unit_info` and/or *data* keyword argument processing.
1 parent 1ee4d65 commit c548924
Copy full SHA for c548924

File tree

Expand file treeCollapse file tree

1 file changed

+19
-30
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+19
-30
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+19-30Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3282,39 +3282,33 @@ def errorbar(self, x, y, yerr=None, xerr=None,
32823282
if not np.iterable(yerr):
32833283
yerr = [yerr] * len(y)
32843284

3285-
plot_line = (fmt.lower() != 'none')
32863285
label = kwargs.pop("label", None)
3286+
kwargs['label'] = '_nolegend_'
3287+
3288+
# Create the main line and determine overall kwargs for child artists.
3289+
# We avoid calling self.plot() directly, or self._get_lines(), because
3290+
# that would call self._process_unit_info again, and do other indirect
3291+
# data processing.
3292+
(data_line, base_style), = self._get_lines._plot_args(
3293+
(x, y) if fmt == '' else (x, y, fmt), kwargs, return_kwargs=True)
3294+
3295+
# Do this after creating `data_line` to avoid modifying `base_style`.
3296+
if barsabove:
3297+
data_line.set_zorder(kwargs['zorder'] - .1)
3298+
else:
3299+
data_line.set_zorder(kwargs['zorder'] + .1)
32873300

3288-
if fmt == '':
3289-
fmt_style_kwargs = {}
3301+
# Add line to plot, or throw it away and use it to determine kwargs.
3302+
if fmt.lower() != 'none':
3303+
self.add_line(data_line)
32903304
else:
3291-
fmt_style_kwargs = {k: v for k, v in
3292-
zip(('linestyle', 'marker', 'color'),
3293-
_process_plot_format(fmt))
3294-
if v is not None}
3295-
if fmt == 'none':
3296-
# Remove alpha=0 color that _process_plot_format returns
3297-
fmt_style_kwargs.pop('color')
3298-
3299-
base_style = self._get_lines._getdefaults(
3300-
set(), {**fmt_style_kwargs, **kwargs})
3301-
if 'color' in kwargs:
3302-
base_style['color'] = kwargs.pop('color')
3303-
base_style['label'] = '_nolegend_'
3304-
base_style.update(fmt_style_kwargs)
3305+
data_line = None
3306+
33053307
if 'color' not in base_style:
33063308
base_style['color'] = 'C0'
33073309
if ecolor is None:
33083310
ecolor = base_style['color']
33093311

3310-
# make the style dict for the 'normal' plot line
3311-
plot_line_style = {
3312-
**base_style,
3313-
**kwargs,
3314-
'zorder': (kwargs['zorder'] - .1 if barsabove else
3315-
kwargs['zorder'] + .1),
3316-
}
3317-
33183312
# Make the style dict for the line collections (the bars), ejecting any
33193313
# marker information from format string.
33203314
eb_lines_style = dict(base_style)
@@ -3359,11 +3353,6 @@ def errorbar(self, x, y, yerr=None, xerr=None,
33593353
eb_cap_style[key] = kwargs[key]
33603354
eb_cap_style['color'] = ecolor
33613355

3362-
data_line = None
3363-
if plot_line:
3364-
data_line = mlines.Line2D(x, y, **plot_line_style)
3365-
self.add_line(data_line)
3366-
33673356
barcols = []
33683357
caplines = []
33693358

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.