From e1f646490b198f5283672923bc76d0445fa059c9 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Mon, 27 Feb 2017 14:59:45 +0000 Subject: [PATCH 1/4] Plot errorbars if fmt=='none' --- lib/matplotlib/axes/_axes.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index d25a91bdc2a0..d2c50c1b5e78 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -2820,6 +2820,9 @@ def errorbar(self, x, y, yerr=None, xerr=None, fmt_style_kwargs = {k: v for k, v in zip(('linestyle', 'marker', 'color'), _process_plot_format(fmt)) if v is not None} + if fmt == 'none': + # Remove alpha=0 color that _process_plot_format returns + fmt_style_kwargs.pop('color') if ('color' in kwargs or 'color' in fmt_style_kwargs or ecolor is not None): From 521f668760170cdd638565155ce9e4675ca94a8f Mon Sep 17 00:00:00 2001 From: David Stansby Date: Mon, 27 Feb 2017 15:00:04 +0000 Subject: [PATCH 2/4] Add test for fmt=='none' --- lib/matplotlib/tests/test_axes.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 223625d7610c..7bb86a791e19 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -2454,6 +2454,17 @@ def test_errorbar_limits(): ax.set_title('Errorbar upper and lower limits') +def test_errobar_nonefmt(): + # Check that passing 'none' as a format still plots errorbars + x = np.arange(5) + y = np.arange(5) + + plotline, _, barlines = plt.errorbar(x, y, xerr=1, yerr=1, fmt='none') + assert plotline is None + for errbar in barlines: + assert np.any(errbar.get_color() != [0, 0, 0, 0]) + + @image_comparison(baseline_images=['hist_stacked_stepfilled', 'hist_stacked_stepfilled']) def test_hist_stacked_stepfilled(): From d46660dc7672d25145205118a8aaf1430aec78f6 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Mon, 27 Feb 2017 16:05:57 +0000 Subject: [PATCH 3/4] Check plotted bars are color C0 --- lib/matplotlib/tests/test_axes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 7bb86a791e19..fa28b5eb2c72 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -2462,7 +2462,7 @@ def test_errobar_nonefmt(): plotline, _, barlines = plt.errorbar(x, y, xerr=1, yerr=1, fmt='none') assert plotline is None for errbar in barlines: - assert np.any(errbar.get_color() != [0, 0, 0, 0]) + assert np.all(errbar.get_color() == mcolors.to_rgba('C0')) @image_comparison(baseline_images=['hist_stacked_stepfilled', From ba21fd81045528791e5e666e3c57d8728e3bbe59 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Mon, 27 Feb 2017 17:22:11 +0000 Subject: [PATCH 4/4] Add cleanup to new test --- lib/matplotlib/tests/test_axes.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index fa28b5eb2c72..cd6bdf7b2139 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -2454,6 +2454,7 @@ def test_errorbar_limits(): ax.set_title('Errorbar upper and lower limits') +@cleanup def test_errobar_nonefmt(): # Check that passing 'none' as a format still plots errorbars x = np.arange(5)