Skip to content

Commit 6ea55ca

Browse files
useidemaisacholaQuLogic
authored andcommitted
Backport PR matplotlib#29895: The 'lines.markeredgecolor' now doesn't interfere on the color of errorbar caps
1 parent d397c52 commit 6ea55ca

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3780,7 +3780,7 @@ def _upcast_err(err):
37803780
'zorder', 'rasterized'):
37813781
if key in kwargs:
37823782
eb_cap_style[key] = kwargs[key]
3783-
eb_cap_style['color'] = ecolor
3783+
eb_cap_style["markeredgecolor"] = ecolor
37843784

37853785
barcols = []
37863786
caplines = {'x': [], 'y': []}

lib/matplotlib/tests/test_axes.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9618,3 +9618,29 @@ def test_axes_set_position_external_bbox_unchanged(fig_test, fig_ref):
96189618
ax_test.set_position([0.25, 0.25, 0.5, 0.5])
96199619
assert (bbox.x0, bbox.y0, bbox.width, bbox.height) == (0.0, 0.0, 1.0, 1.0)
96209620
ax_ref = fig_ref.add_axes([0.25, 0.25, 0.5, 0.5])
9621+
9622+
9623+
def test_caps_color():
9624+
# Creates a simple plot with error bars and a specified ecolor
9625+
x = np.linspace(0, 10, 10)
9626+
mpl.rcParams['lines.markeredgecolor'] = 'green'
9627+
ecolor = 'red'
9628+
9629+
fig, ax = plt.subplots()
9630+
errorbars = ax.errorbar(x, np.sin(x), yerr=0.1, ecolor=ecolor)
9631+
9632+
# Tests if the caps have the specified color
9633+
for cap in errorbars[2]:
9634+
assert mcolors.same_color(cap.get_edgecolor(), ecolor)
9635+
9636+
9637+
def test_caps_no_ecolor():
9638+
# Creates a simple plot with error bars without specifying ecolor
9639+
x = np.linspace(0, 10, 10)
9640+
mpl.rcParams['lines.markeredgecolor'] = 'green'
9641+
fig, ax = plt.subplots()
9642+
errorbars = ax.errorbar(x, np.sin(x), yerr=0.1)
9643+
9644+
# Tests if the caps have the default color (blue)
9645+
for cap in errorbars[2]:
9646+
assert mcolors.same_color(cap.get_edgecolor(), "blue")

0 commit comments

Comments
 (0)