Skip to content

Commit b6f17f3

Browse files
authored
Merge pull request #8163 from dstansby/errbar-none-fmt
FIX: Plot errorbars when fmt == 'none'
2 parents cdc493d + ba21fd8 commit b6f17f3

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/matplotlib/axes/_axes.py

+3
Original file line numberDiff line numberDiff line change
@@ -2820,6 +2820,9 @@ def errorbar(self, x, y, yerr=None, xerr=None,
28202820
fmt_style_kwargs = {k: v for k, v in
28212821
zip(('linestyle', 'marker', 'color'),
28222822
_process_plot_format(fmt)) if v is not None}
2823+
if fmt == 'none':
2824+
# Remove alpha=0 color that _process_plot_format returns
2825+
fmt_style_kwargs.pop('color')
28232826

28242827
if ('color' in kwargs or 'color' in fmt_style_kwargs or
28252828
ecolor is not None):

lib/matplotlib/tests/test_axes.py

+12
Original file line numberDiff line numberDiff line change
@@ -2454,6 +2454,18 @@ def test_errorbar_limits():
24542454
ax.set_title('Errorbar upper and lower limits')
24552455

24562456

2457+
@cleanup
2458+
def test_errobar_nonefmt():
2459+
# Check that passing 'none' as a format still plots errorbars
2460+
x = np.arange(5)
2461+
y = np.arange(5)
2462+
2463+
plotline, _, barlines = plt.errorbar(x, y, xerr=1, yerr=1, fmt='none')
2464+
assert plotline is None
2465+
for errbar in barlines:
2466+
assert np.all(errbar.get_color() == mcolors.to_rgba('C0'))
2467+
2468+
24572469
@image_comparison(baseline_images=['hist_stacked_stepfilled',
24582470
'hist_stacked_stepfilled'])
24592471
def test_hist_stacked_stepfilled():

0 commit comments

Comments
 (0)