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

Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4154,6 +4154,7 @@ def _upcast_err(err):

# Make the style dict for the line collections (the bars).
eb_lines_style = {**base_style, 'color': ecolor}
elinewidth = mpl._val_or_rc(elinewidth, "errorbar.elinewidth")

if elinewidth is not None:
eb_lines_style['linewidth'] = elinewidth
Expand All @@ -4170,6 +4171,8 @@ 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")

if capsize > 0:
eb_cap_style['markersize'] = 2. * capsize
if capthick is not None:
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 # line width of error bar lines in points


## ***************************************************************************
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 @@ -2918,6 +2920,17 @@ class _Subsection:
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."
),
_Section("Histogram plots"),
_Param(
"hist.bins",
Expand Down
19 changes: 19 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10155,3 +10155,22 @@ def test_animated_artists_not_drawn_by_default():

mocked_im_draw.assert_not_called()
mocked_ln_draw.assert_not_called()

Comment thread
Hannan7812 marked this conversation as resolved.

def test_errorbar_uses_rcparams():
with mpl.rc_context({
"errorbar.capsize": 5.0,
"errorbar.capthick": 2.5,
"errorbar.elinewidth": 1.75,
}):
fig, ax = plt.subplots()
eb = ax.errorbar([0, 1, 2], [1, 2, 3], yerr=[0.1, 0.2, 0.3], fmt="none")

data_line, caplines, barlinecols = eb.lines
assert data_line is None
assert caplines

assert_allclose([cap.get_markersize() for cap in caplines], 10.0)
assert_allclose([cap.get_markeredgewidth() for cap in caplines], 2.5)
for barcol in barlinecols:
assert_allclose(barcol.get_linewidths(), 1.75)
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