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

Skip to content

Adding elinestyle property to errorbar #29879

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 22 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5019e57
Adding elinestyle property to errorbar and test case
hasanrashid Apr 6, 2025
cf79005
whitespaces in testcase
hasanrashid Apr 6, 2025
dd2be27
Merge branch 'matplotlib:main' into enh-29681-hr
hasanrashid Apr 8, 2025
3f139f2
Update lib/matplotlib/axes/_axes.py
hasanrashid Apr 8, 2025
2705eab
Merge branch 'matplotlib:main' into enh-29681-hr
hasanrashid Apr 9, 2025
7c68dd0
Merge branch 'matplotlib:main' into enh-29681-hr
hasanrashid Apr 13, 2025
596bcde
Update set eb_line_style and fix formatting issues
hasanrashid Apr 13, 2025
73137f6
Remove extra line from test_axes
hasanrashid Apr 13, 2025
0059043
Break line to reduce width in text_axes.py
hasanrashid Apr 13, 2025
2bdf70b
Remove trailing whitespaces from axes and test_axes.py
hasanrashid Apr 13, 2025
e412775
Move elinestyle to the end of the list
hasanrashid Apr 13, 2025
a02930f
Shorten line length in axes.py
hasanrashid Apr 13, 2025
26a73b4
accessing the correct property 'linestyle' in eb_line_style
hasanrashid Apr 13, 2025
9d0dece
removing unused code
hasanrashid Apr 13, 2025
9bb00ab
Merge branch 'matplotlib:main' into enh-29681-hr
hasanrashid Apr 20, 2025
896678f
Update lib/matplotlib/axes/_axes.pyi
hasanrashid Apr 20, 2025
2e49747
pyplot.py unwanted changes reverted
hasanrashid Apr 26, 2025
44638f3
Adding extra blank lines to fix style errors, and removing unnecessar…
hasanrashid Apr 27, 2025
c503592
Merge branch 'matplotlib:main' into enh-29681-hr
hasanrashid Apr 27, 2025
0e36c50
Updating test_axes.py tp test for dashed lines instead of default
hasanrashid Apr 29, 2025
430ef24
Merge branch 'matplotlib:main' into enh-29681-hr
hasanrashid Apr 29, 2025
ff0370a
Style fix
timhoffm Apr 29, 2025
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
12 changes: 11 additions & 1 deletion lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3463,7 +3463,8 @@ def _errorevery_to_mask(x, errorevery):
def errorbar(self, x, y, yerr=None, xerr=None,
fmt='', ecolor=None, elinewidth=None, capsize=None,
barsabove=False, lolims=False, uplims=False,
xlolims=False, xuplims=False, errorevery=1, capthick=None,
xlolims=False, xuplims=False, errorevery=1,
capthick=None, elinestyle=None,
**kwargs):
"""
Plot y versus x as lines and/or markers with attached errorbars.
Expand Down Expand Up @@ -3511,6 +3512,12 @@ def errorbar(self, x, y, yerr=None, xerr=None,
The linewidth of the errorbar lines. If None, the linewidth of
the current style is used.

elinestyle : str or tuple, default: 'solid'
The linestyle of the errorbar lines.
Valid values for linestyles include {'-', '--', '-.',
':', '', (offset, on-off-seq)}. See `.Line2D.set_linestyle` for a
complete description.

capsize : float, default: :rc:`errorbar.capsize`
The length of the error bar caps in points.

Expand Down Expand Up @@ -3712,6 +3719,9 @@ def _upcast_err(err):
if key in kwargs:
eb_lines_style[key] = kwargs[key]

if elinestyle is not None:
eb_lines_style['linestyle'] = elinestyle

# Make the style dict for caps (the "hats").
eb_cap_style = {**base_style, 'linestyle': 'none'}
capsize = mpl._val_or_rc(capsize, "errorbar.capsize")
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/axes/_axes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ class Axes(_AxesBase):
*,
ecolor: ColorType | None = ...,
elinewidth: float | None = ...,
elinestyle: LineStyleType | None = ...,
capsize: float | None = ...,
barsabove: bool = ...,
lolims: bool | ArrayLike = ...,
Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3281,6 +3281,7 @@ def errorbar(
xuplims: bool | ArrayLike = False,
errorevery: int | tuple[int, int] = 1,
capthick: float | None = None,
elinestyle: LineStyleType | None = None,
*,
data=None,
**kwargs,
Expand All @@ -3301,6 +3302,7 @@ def errorbar(
xuplims=xuplims,
errorevery=errorevery,
capthick=capthick,
elinestyle=elinestyle,
**({"data": data} if data is not None else {}),
**kwargs,
)
Expand Down
8 changes: 8 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4526,6 +4526,14 @@ def test_errorbar_linewidth_type(elinewidth):
plt.errorbar([1, 2, 3], [1, 2, 3], yerr=[1, 2, 3], elinewidth=elinewidth)


def test_errorbar_linestyle_type():
eb = plt.errorbar([1, 2, 3], [1, 2, 3],
yerr=[1, 2, 3], elinestyle='--')
errorlines = eb[-1][0]
errorlinestyle = errorlines.get_linestyle()
assert errorlinestyle == [(0, (6, 6))]


@check_figures_equal()
def test_errorbar_nan(fig_test, fig_ref):
ax = fig_test.add_subplot()
Expand Down
Loading