Skip to content

Commit 596bcde

Browse files
committed
Update set eb_line_style and fix formatting issues
1 parent 7c68dd0 commit 596bcde

File tree

4 files changed

+16
-42
lines changed

4 files changed

+16
-42
lines changed

lib/matplotlib/axes/_axes.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -3453,14 +3453,15 @@ def _errorevery_to_mask(x, errorevery):
34533453
everymask[errorevery] = True
34543454
return everymask
34553455

3456-
@_api.make_keyword_only("3.10", "ecolor")
3456+
@_api.make_keyword_only("3.10", "elinestyle")
34573457
@_preprocess_data(replace_names=["x", "y", "xerr", "yerr"],
34583458
label_namer="y")
34593459
@_docstring.interpd
34603460
def errorbar(self, x, y, yerr=None, xerr=None,
3461-
fmt='', ecolor=None, elinewidth=None, elinestyle=None, capsize=None,
3461+
fmt='', ecolor=None, elinewidth=None, capsize=None,
34623462
barsabove=False, lolims=False, uplims=False,
34633463
xlolims=False, xuplims=False, errorevery=1, capthick=None,
3464+
elinestyle=None,
34643465
**kwargs):
34653466
"""
34663467
Plot y versus x as lines and/or markers with attached errorbars.
@@ -3715,6 +3716,12 @@ def _upcast_err(err):
37153716
if key in kwargs:
37163717
eb_lines_style[key] = kwargs[key]
37173718

3719+
if elinestyle is not None:
3720+
eb_lines_style['style'] = elinestyle
3721+
#if xerr is not None and yerr is not None:
3722+
#barcols[-2].set_linestyle(elinestyle)
3723+
#barcols[-1].set_linestyle(elinestyle)
3724+
37183725
# Make the style dict for caps (the "hats").
37193726
eb_cap_style = {**base_style, 'linestyle': 'none'}
37203727
capsize = mpl._val_or_rc(capsize, "errorbar.capsize")
@@ -3824,17 +3831,9 @@ def apply_mask(arrays, mask):
38243831
else:
38253832
for axis in caplines:
38263833
for l in caplines[axis]:
3827-
self.add_line(l)
3828-
3834+
self.add_line(l)
38293835
self._request_autoscale_view()
38303836
caplines = caplines['x'] + caplines['y']
3831-
3832-
if(elinestyle is not None):
3833-
if(xerr is not None and yerr is not None):
3834-
barcols[-2].set_linestyle(elinestyle)
3835-
barcols[-1].set_linestyle(elinestyle)
3836-
3837-
38383837
errorbar_container = ErrorbarContainer(
38393838
(data_line, tuple(caplines), tuple(barcols)),
38403839
has_xerr=(xerr is not None), has_yerr=(yerr is not None),

lib/matplotlib/axes/_axes.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ class Axes(_AxesBase):
315315
*,
316316
ecolor: ColorType | None = ...,
317317
elinewidth: float | None = ...,
318-
elinestyle: str | None=...,
318+
elinestyle: LineStyleType | None=...,
319319
capsize: float | None = ...,
320320
barsabove: bool = ...,
321321
lolims: bool | ArrayLike = ...,

lib/matplotlib/pyplot.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -3041,7 +3041,7 @@ def bar_label(
30413041
*,
30423042
fmt: str | Callable[[float], str] = "%g",
30433043
label_type: Literal["center", "edge"] = "edge",
3044-
padding: float | ArrayLike = 0,
3044+
padding: float = 0,
30453045
**kwargs,
30463046
) -> list[Annotation]:
30473047
return gca().bar_label(
@@ -4117,9 +4117,6 @@ def streamplot(
41174117
integration_direction="both",
41184118
broken_streamlines=True,
41194119
*,
4120-
integration_max_step_scale=1.0,
4121-
integration_max_error_scale=1.0,
4122-
num_arrows=1,
41234120
data=None,
41244121
):
41254122
__ret = gca().streamplot(
@@ -4141,9 +4138,6 @@ def streamplot(
41414138
maxlength=maxlength,
41424139
integration_direction=integration_direction,
41434140
broken_streamlines=broken_streamlines,
4144-
integration_max_step_scale=integration_max_step_scale,
4145-
integration_max_error_scale=integration_max_error_scale,
4146-
num_arrows=num_arrows,
41474141
**({"data": data} if data is not None else {}),
41484142
)
41494143
sci(__ret.lines)
@@ -4291,8 +4285,6 @@ def violinplot(
42914285
| Callable[[GaussianKDE], float]
42924286
| None = None,
42934287
side: Literal["both", "low", "high"] = "both",
4294-
facecolor: Sequence[ColorType] | ColorType | None = None,
4295-
linecolor: Sequence[ColorType] | ColorType | None = None,
42964288
*,
42974289
data=None,
42984290
) -> dict[str, Collection]:
@@ -4309,8 +4301,6 @@ def violinplot(
43094301
points=points,
43104302
bw_method=bw_method,
43114303
side=side,
4312-
facecolor=facecolor,
4313-
linecolor=linecolor,
43144304
**({"data": data} if data is not None else {}),
43154305
)
43164306

lib/matplotlib/tests/test_axes.py

+4-19
Original file line numberDiff line numberDiff line change
@@ -4527,26 +4527,11 @@ def test_errorbar_linewidth_type(elinewidth):
45274527

45284528
def test_errorbar_linestyle_type():
45294529
eb = plt.errorbar([1, 2, 3], [1, 2, 3], yerr=[1, 2, 3], elinestyle='-')
4530-
assert eb[-1][0].get_linestyle(), '-'
4531-
eb = plt.errorbar([1, 2, 3], [1, 2, 3], yerr=[1, 2, 3], elinestyle='--')
4532-
assert eb[-1][0].get_linestyle(), '--'
4533-
eb = plt.errorbar([1, 2, 3], [1, 2, 3], yerr=[1, 2, 3], elinestyle='-.')
4534-
assert eb[-1][0].get_linestyle(), '-.'
4535-
eb = plt.errorbar([1, 2, 3], [1, 2, 3], yerr=[1, 2, 3], elinestyle=':')
4536-
assert eb[-1][0].get_linestyle(), ':'
4537-
4538-
eb = plt.errorbar([1, 2, 3], [1, 2, 3], xerr=[1, 2, 3], yerr=[1, 2, 3], elinestyle='-')
4539-
assert eb[-1][0].get_linestyle(), '-'
4540-
assert eb[-1][1].get_linestyle(), '-'
4541-
eb = plt.errorbar([1, 2, 3], [1, 2, 3], xerr=[1, 2, 3], yerr=[1, 2, 3], elinestyle='--')
4542-
assert eb[-1][0].get_linestyle(), '--'
4543-
assert eb[-1][1].get_linestyle(), '--'
4544-
eb = plt.errorbar([1, 2, 3], [1, 2, 3], xerr=[1, 2, 3], yerr=[1, 2, 3], elinestyle='-.')
4545-
assert eb[-1][0].get_linestyle(), '-.'
4546-
assert eb[-1][1].get_linestyle(), '-.'
4530+
assert eb[-1][0].get_linestyle() == '-'
4531+
45474532
eb = plt.errorbar([1, 2, 3], [1, 2, 3], xerr=[1, 2, 3], yerr=[1, 2, 3], elinestyle=':')
4548-
assert eb[-1][0].get_linestyle(), ':'
4549-
assert eb[-1][1].get_linestyle(), ':'
4533+
assert eb[-1][0].get_linestyle() == ':'
4534+
assert eb[-1][1].get_linestyle() == ':'
45504535

45514536
@check_figures_equal()
45524537
def test_errorbar_nan(fig_test, fig_ref):

0 commit comments

Comments
 (0)