Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 20bdd72

Browse filesBrowse files
Don't override errorbar caps with 'lines.markeredgecolor' rcParam (matplotlib#29895)
* Fix matplotlib#29780 : color of errorbar caps affected by markeredgecolor To solve this, we needed to ensure that the caps would use the specified ecolor independently of the global mpl.rcParams['lines.markeredgecolor']. This was achieved by setting the marker edge color for the caps separately, rather than relying on the global configuration. * Taking whitespaces * Update lib/matplotlib/tests/test_axes.py * Update lib/matplotlib/tests/test_axes.py Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> * Alteration of the tests --------- Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
1 parent f0a1206 commit 20bdd72
Copy full SHA for 20bdd72

File tree

2 files changed

+29
-1
lines changed
Filter options

2 files changed

+29
-1
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3739,7 +3739,7 @@ def _upcast_err(err):
37393739
'zorder', 'rasterized'):
37403740
if key in kwargs:
37413741
eb_cap_style[key] = kwargs[key]
3742-
eb_cap_style['color'] = ecolor
3742+
eb_cap_style["markeredgecolor"] = ecolor
37433743

37443744
barcols = []
37453745
caplines = {'x': [], 'y': []}

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9741,6 +9741,34 @@ def test_bar_shape_mismatch():
97419741
plt.bar(x, height)
97429742

97439743

9744+
def test_caps_color():
9745+
9746+
# Creates a simple plot with error bars and a specified ecolor
9747+
x = np.linspace(0, 10, 10)
9748+
mpl.rcParams['lines.markeredgecolor'] = 'green'
9749+
ecolor = 'red'
9750+
9751+
fig, ax = plt.subplots()
9752+
errorbars = ax.errorbar(x, np.sin(x), yerr=0.1, ecolor=ecolor)
9753+
9754+
# Tests if the caps have the specified color
9755+
for cap in errorbars[2]:
9756+
assert mcolors.same_color(cap.get_edgecolor(), ecolor)
9757+
9758+
9759+
def test_caps_no_ecolor():
9760+
9761+
# Creates a simple plot with error bars without specifying ecolor
9762+
x = np.linspace(0, 10, 10)
9763+
mpl.rcParams['lines.markeredgecolor'] = 'green'
9764+
fig, ax = plt.subplots()
9765+
errorbars = ax.errorbar(x, np.sin(x), yerr=0.1)
9766+
9767+
# Tests if the caps have the default color (blue)
9768+
for cap in errorbars[2]:
9769+
assert mcolors.same_color(cap.get_edgecolor(), "blue")
9770+
9771+
97449772
def test_pie_non_finite_values():
97459773
fig, ax = plt.subplots()
97469774
df = [5, float('nan'), float('inf')]

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.