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

Skip to content

Commit 3d4e78b

Browse files
authored
Merge pull request #12442 from anntzer/drawstyle-linestyle
Deprecate passing drawstyle with linestyle as single string.
2 parents de3c5fb + d35c3a7 commit 3d4e78b

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Passing a Line2D's drawstyle together with the linestyle is deprecated
2+
``````````````````````````````````````````````````````````````````````
3+
4+
Instead of ``plt.plot(..., linestyle="steps--")``, use ``plt.plot(...,
5+
linestyle="--", drawstyle="steps")``. ``ds`` is now an alias for ``drawstyle``.

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,8 +2048,7 @@ def step(self, x, y, *args, where='pre', **kwargs):
20482048
if where not in ('pre', 'post', 'mid'):
20492049
raise ValueError("'where' argument to step must be "
20502050
"'pre', 'post' or 'mid'")
2051-
kwargs['linestyle'] = 'steps-' + where + kwargs.get('linestyle', '')
2052-
2051+
kwargs['drawstyle'] = 'steps-' + where
20532052
return self.plot(x, y, *args, **kwargs)
20542053

20552054
@_preprocess_data(replace_names=["x", "left",

lib/matplotlib/lines.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ def _slice_or_none(in_v, slc):
207207
@cbook._define_aliases({
208208
"antialiased": ["aa"],
209209
"color": ["c"],
210+
"drawstyle": ["ds"],
210211
"linestyle": ["ls"],
211212
"linewidth": ["lw"],
212213
"markeredgecolor": ["mec"],
@@ -1133,6 +1134,13 @@ def _split_drawstyle_linestyle(self, ls):
11331134
"""
11341135
for ds in self.drawStyleKeys: # long names are first in the list
11351136
if ls.startswith(ds):
1137+
cbook.warn_deprecated(
1138+
"3.1", message="Passing the drawstyle with the linestyle "
1139+
"as a single string is deprecated since Matplotlib "
1140+
"%(since)s and support will be removed %(removal)s; "
1141+
"please pass the drawstyle separately using the drawstyle "
1142+
"keyword argument to Line2D or set_drawstyle() method (or "
1143+
"ds/set_ds()).")
11361144
return ds, ls[len(ds):] or '-'
11371145
return None, ls
11381146

0 commit comments

Comments
 (0)