Skip to content

Commit 407a460

Browse files
authored
Merge pull request #9952 from as691454/my-branch
Errorbars accept marker_options and follow prop_cycle
2 parents f867e21 + d967992 commit 407a460

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

lib/matplotlib/axes/_axes.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -3058,7 +3058,10 @@ def errorbar(self, x, y, yerr=None, xerr=None,
30583058
plot_line = (fmt.lower() != 'none')
30593059
label = kwargs.pop("label", None)
30603060

3061-
fmt_style_kwargs = {k: v for k, v in
3061+
if fmt == '':
3062+
fmt_style_kwargs = {}
3063+
else:
3064+
fmt_style_kwargs = {k: v for k, v in
30623065
zip(('linestyle', 'marker', 'color'),
30633066
_process_plot_format(fmt)) if v is not None}
30643067
if fmt == 'none':
@@ -3122,6 +3125,9 @@ def errorbar(self, x, y, yerr=None, xerr=None,
31223125
eb_cap_style = dict(base_style)
31233126
# eject any marker information from format string
31243127
eb_cap_style.pop('marker', None)
3128+
eb_lines_style.pop('markerfacecolor', None)
3129+
eb_lines_style.pop('markeredgewidth', None)
3130+
eb_lines_style.pop('markeredgecolor', None)
31253131
eb_cap_style.pop('ls', None)
31263132
eb_cap_style['linestyle'] = 'none'
31273133
if capsize is None:

lib/matplotlib/tests/test_axes.py

+10
Original file line numberDiff line numberDiff line change
@@ -2817,6 +2817,16 @@ def test_errobar_nonefmt():
28172817
assert np.all(errbar.get_color() == mcolors.to_rgba('C0'))
28182818

28192819

2820+
@image_comparison(baseline_images=['errorbar_with_prop_cycle'],
2821+
extensions=['png'], style='mpl20', remove_text=True)
2822+
def test_errorbar_with_prop_cycle():
2823+
_cycle = cycler(ls=['--', ':'], marker=['s', 's'], mfc=['k', 'w'])
2824+
plt.rc("axes", prop_cycle=_cycle)
2825+
fig, ax = plt.subplots()
2826+
ax.errorbar(x=[2, 4, 10], y=[3, 2, 4], yerr=0.5)
2827+
ax.errorbar(x=[2, 4, 10], y=[6, 4, 2], yerr=0.5)
2828+
2829+
28202830
@image_comparison(baseline_images=['hist_stacked_stepfilled',
28212831
'hist_stacked_stepfilled'])
28222832
def test_hist_stacked_stepfilled():

0 commit comments

Comments
 (0)