From 4ebff479a1088eb47e7d1e4a15eeea30204513b1 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Thu, 3 Mar 2022 17:55:30 -0500 Subject: [PATCH] FIX: do not pass dashes to collections in errorbar *dashes* is another Line2D only kwarg that should not be passed to all of the artists created. closes #22590 --- lib/matplotlib/axes/_axes.py | 3 ++- lib/matplotlib/tests/test_axes.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 606f3c83ceef..3026e681f742 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -3411,7 +3411,8 @@ def _upcast_err(err): for key in ['marker', 'markersize', 'markerfacecolor', 'markeredgewidth', 'markeredgecolor', 'markevery', 'linestyle', 'fillstyle', 'drawstyle', 'dash_capstyle', - 'dash_joinstyle', 'solid_capstyle', 'solid_joinstyle']: + 'dash_joinstyle', 'solid_capstyle', 'solid_joinstyle', + 'dashes']: base_style.pop(key, None) # Make the style dict for the line collections (the bars). diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index ddb1e3bbdd51..b2bc70ff6143 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -679,6 +679,20 @@ def test_plot_format_kwarg_redundant(): plt.errorbar([0], [0], fmt='none', color='blue') +@check_figures_equal(extensions=["png"]) +def test_errorbar_dashes(fig_test, fig_ref): + x = [1, 2, 3, 4] + y = np.sin(x) + + ax_ref = fig_ref.gca() + ax_test = fig_test.gca() + + line, *_ = ax_ref.errorbar(x, y, xerr=np.abs(y), yerr=np.abs(y)) + line.set_dashes([2, 2]) + + ax_test.errorbar(x, y, xerr=np.abs(y), yerr=np.abs(y), dashes=[2, 2]) + + @image_comparison(['single_point', 'single_point']) def test_single_point(): # Issue #1796: don't let lines.marker affect the grid