8000 The 'lines.markeredgecolor' now doesn't interfere on the color of errorbar caps by useidemaisachola · Pull Request #29895 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

The 'lines.markeredgecolor' now doesn't interfere on the color of errorbar caps #29895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 15, 2025
2 changes: 1 addition & 1 deletion lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3726,7 +3726,7 @@ def _upcast_err(err):
'zorder', 'rasterized'):
if key in kwargs:
eb_cap_style[key] = kwargs[key]
eb_cap_style['color'] = ecolor
eb_cap_style["markeredgecolor"] = ecolor

barcols = []
caplines = {'x': [], 'y': []}
Expand Down
33 changes: 33 additions & 0 deletions lib/matplotlib/tests/test_axes.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -9733,6 +9733,39 @@ def test_bar_shape_mismatch():
plt.bar(x, height)


def test_caps_color():

# Creates a simple plot with error bars and a specified ecolor
x = np.linspace(0, 10, 10)
y = np.sin(x)
yerr = 0.1
mpl.rcParams['lines.markeredgecolor'] = 'green'
ecolor = 'red'

fig, ax = plt.subplots()
errorbars = ax.errorbar(x, y, yerr=yerr, ecolor=ecolor, fmt='o', capsize=5)

# Tests if the caps have the specified color
for cap in errorbars[2]:
assert mcolors.same_color(cap.get_edgecolor(), ecolor)


def test_caps_no_ecolor():

# Creates a simple plot with error bars without specifying ecolor
x = np.linspace(0, 10, 10)
y = np.sin(x)
yerr = 0.1
mpl.rcParams['lines.markeredgecolor'] = 'green'

fig, ax = plt.subplots()
errorbars = ax.errorbar(x, y, yerr=yerr, fmt='o', capsize=5)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above:

Suggested change
y = np.sin(x)
yerr = 0.1
mpl.rcParams['lines.markeredgecolor'] = 'green'
fig, ax = plt.subplots()
errorbars = ax.errorbar(x, y, yerr=yerr, fmt='o', capsize=5)
mpl.rcParams['lines.markeredgecolor'] = 'green'
fig, ax = plt.subplots()
errorbars = ax.errorbar(x, np.sin(x), yerr=0.1)


# Tesrts if the caps have the default color (blue)
for cap in errorbars[2]:
assert mcolors.same_color(cap.get_edgecolor(), "blue")


def test_pie_non_finite_values():
fig, ax = plt.subplots()
df = [5, float('nan'), float('inf')]
Expand Down
Loading
0