Skip to content

Commit d35c3a7

Browse files
committed
Deprecate passing drawstyle with linestyle as single string.
Instead of `plt.plot(..., linestyle="steps--")`, use `plt.plot(..., linestyle="--", drawstyle="steps")`. `ds` is now an alias for `drawstyle`. Note that `plt.plot(..., "steps--")` already doesn't work (due to confusion as to whether "steps" is a color, a marker or a drawstyle). The end goal is to simplify and rationalize linestyle specification as rcParams vs. as arguments.
1 parent 9cffe0e commit d35c3a7

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed
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

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

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

lib/matplotlib/lines.py

+8
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)