Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4170,10 +4170,14 @@ def _upcast_err(err):
# Make the style dict for caps (the "hats").
eb_cap_style = {**base_style, 'linestyle': 'none'}
capsize = mpl._val_or_rc(capsize, "errorbar.capsize")
capthick = mpl._val_or_rc(capthick, "errorbar.capthick")
elinewidth = mpl._val_or_rc(elinewidth, "errorbar.elinewidth")
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

New behavior (rcParams-backed defaults for capthick/elinewidth) is introduced here but there are no tests exercising rcParams['errorbar.capthick'] / rcParams['errorbar.elinewidth'] or their precedence vs explicit elinewidth/linewidth kwargs. Please add a test (likely in lib/matplotlib/tests/test_axes.py near existing errorbar tests) that sets these rcParams and asserts the resulting cap markeredgewidth and errorbar LineCollection linewidth.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This must be moved before l.4158

if capsize > 0:
eb_cap_style['markersize'] = 2. * capsize
if capthick is not None:
eb_cap_style['markeredgewidth'] = capthick
if eb_lines_style is not None:
eb_lines_style['linewidth'] = elinewidth
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

elinewidth is already handled earlier when building eb_lines_style; the new _val_or_rc block later unconditionally overwrites eb_lines_style['linewidth'] (even when the resolved rcParam is None). This can (a) clobber an explicitly provided linewidth kwarg and (b) set linewidth=None in the collection style, which may break downstream setters. Resolve elinewidth (including rc fallback) once, apply it only when non-None, and preserve the existing precedence where explicit elinewidth/linewidth overrides the rcParam default.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't touch eb_lines_style again here. It should be built consistently in l.4155ff


# For backwards-compat, allow explicit setting of
# 'markeredgewidth' to over-ride capthick.
Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/mpl-data/matplotlibrc
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,8 @@
## * ERRORBAR PLOTS *
## ***************************************************************************
#errorbar.capsize: 0 # length of end cap on error bars in pixels
#errorbar.capthick: None # thickness of end cap on error bars in points;
#errorbar.elinewidth: None # thickness of error bar lines in points;
Comment thread
Hannan7812 marked this conversation as resolved.
Outdated


## ***************************************************************************
Expand Down
13 changes: 13 additions & 0 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,8 @@ def _convert_validator_spec(key, conv):

# errorbar props
"errorbar.capsize": validate_float,
"errorbar.capthick": validate_float_or_None,
"errorbar.elinewidth": validate_float_or_None,

Comment thread
Hannan7812 marked this conversation as resolved.
# axis props
# alignment of x/y axis title
Expand Down Expand Up @@ -2856,6 +2858,17 @@ class _Param:
validator=validate_float,
description="length of end cap on error bars in pixels"
),
_Param(
"errorbar.capthick",
default=None,
Comment thread
Hannan7812 marked this conversation as resolved.
validator=validate_float_or_None,
description="thickness of end cap on error bars in points."),
_Param(
"errorbar.elinewidth",
default=None,
validator=validate_float_or_None,
description="line width of the error bar lines in points."
),
_Param(
"hist.bins",
default=10,
Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@
"date.interval_multiples",
"docstring.hardcopy",
"errorbar.capsize",
"errorbar.capthick",
"errorbar.elinewidth",
"figure.autolayout",
"figure.constrained_layout.h_pad",
"figure.constrained_layout.hspace",
Expand Down
Loading