ENH: Adds `errorbar.capthick` and `errorbar.elinewidth` to mplstyle (… · matplotlib/matplotlib@e3d6dfc · GitHub
Skip to content

Commit e3d6dfc

Browse files
Hannan7812CopilottimhoffmAlbertUnruh
authored
ENH: Adds errorbar.capthick and errorbar.elinewidth to mplstyle (#31202)
* Added 2 new rcparams: errorbar.capthick and errorbar.elinewidth * Modified _axes.py to properly render the rcparams * Fixed minor formatting to pass linter tests * Update lib/matplotlib/mpl-data/matplotlibrc Fixed documentation formatting Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Adressed reviewer comments and added a test * DOC: Add sections to rcParams documentation * Apply suggestion from @timhoffm * Update lib/matplotlib/tests/test_axes.py Incorporated suggestion to satisfy linting rule Co-authored-by: AlbertUnruh <73029826+AlbertUnruh@users.noreply.github.com> * Update lib/matplotlib/tests/test_axes.py Incorporated suggestion to pass linting test W291 Co-authored-by: AlbertUnruh <73029826+AlbertUnruh@users.noreply.github.com> * Moved capthick to line 4174 --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Co-authored-by: AlbertUnruh <73029826+AlbertUnruh@users.noreply.github.com>
1 parent 2bd2c45 commit e3d6dfc

5 files changed

Lines changed: 39 additions & 0 deletions

File tree

lib/matplotlib/axes/_axes.py

Lines changed: 3 additions & 0 deletions

lib/matplotlib/mpl-data/matplotlibrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,8 @@
662662
## * ERRORBAR PLOTS *
663663
## ***************************************************************************
664664
#errorbar.capsize: 0 # length of end cap on error bars in pixels
665+
#errorbar.capthick: None # thickness of end cap on error bars in points
666+
#errorbar.elinewidth: None # line width of error bar lines in points
665667

666668

667669
## ***************************************************************************

lib/matplotlib/rcsetup.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,8 @@ def _convert_validator_spec(key, conv):
11141114

11151115
# errorbar props
11161116
"errorbar.capsize": validate_float,
1117+
"errorbar.capthick": validate_float_or_None,
1118+
"errorbar.elinewidth": validate_float_or_None,
11171119

11181120
# axis props
11191121
# alignment of x/y axis title
@@ -2918,6 +2920,17 @@ class _Subsection:
29182920
validator=validate_float,
29192921
description="length of end cap on error bars in pixels"
29202922
),
2923+
_Param(
2924+
"errorbar.capthick",
2925+
default=None,
2926+
validator=validate_float_or_None,
2927+
description="thickness of end cap on error bars in points."),
2928+
_Param(
2929+
"errorbar.elinewidth",
2930+
default=None,
2931+
validator=validate_float_or_None,
2932+
description="line width of the error bar lines in points."
2933+
),
29212934
_Section("Histogram plots"),
29222935
_Param(
29232936
"hist.bins",

lib/matplotlib/tests/test_axes.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10155,3 +10155,22 @@ def test_animated_artists_not_drawn_by_default():
1015510155

1015610156
mocked_im_draw.assert_not_called()
1015710157
mocked_ln_draw.assert_not_called()
10158+
10159+
10160+
def test_errorbar_uses_rcparams():
10161+
with mpl.rc_context({
10162+
"errorbar.capsize": 5.0,
10163+
"errorbar.capthick": 2.5,
10164+
"errorbar.elinewidth": 1.75,
10165+
}):
10166+
fig, ax = plt.subplots()
10167+
eb = ax.errorbar([0, 1, 2], [1, 2, 3], yerr=[0.1, 0.2, 0.3], fmt="none")
10168+
10169+
data_line, caplines, barlinecols = eb.lines
10170+
assert data_line is None
10171+
assert caplines
10172+
10173+
assert_allclose([cap.get_markersize() for cap in caplines], 10.0)
10174+
assert_allclose([cap.get_markeredgewidth() for cap in caplines], 2.5)
10175+
for barcol in barlinecols:
10176+
assert_allclose(barcol.get_linewidths(), 1.75)

lib/matplotlib/typing.py

Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)