Skip to content

Commit 3fb898a

Browse files
committed
Remove support for passing drawstyle in linestyle.
1 parent 19922f3 commit 3fb898a

File tree

2 files changed

+8
-47
lines changed

2 files changed

+8
-47
lines changed

doc/api/api_changes_3.3/behaviour.rst

+8
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,11 @@ and on a Figure (`.Figure.legend` and `.pyplot.figlegend`). Figure legends also
200200
no longer accept the unsupported ``'best'`` location. Previously, invalid Axes
201201
locations would use ``'best'`` and invalid Figure locations would used ``'upper
202202
right'``.
203+
204+
205+
Passing Line2D's *drawstyle* together with *linestyle* is removed
206+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
207+
208+
Instead of ``plt.plot(..., linestyle="steps--")``, use ``plt.plot(...,
209+
linestyle="--", drawstyle="steps")``. ``ds`` is also an alias for
210+
``drawstyle``.

lib/matplotlib/lines.py

-47
Original file line numberDiff line numberDiff line change
@@ -335,16 +335,6 @@ def __init__(self, xdata, ydata,
335335
if solid_joinstyle is None:
336336
solid_joinstyle = rcParams['lines.solid_joinstyle']
337337

338-
if isinstance(linestyle, str):
339-
ds, ls = self._split_drawstyle_linestyle(linestyle)
340-
if ds is not None and drawstyle is not None and ds != drawstyle:
341-
raise ValueError("Inconsistent drawstyle ({!r}) and linestyle "
342-
"({!r})".format(drawstyle, linestyle))
343-
linestyle = ls
344-
345-
if ds is not None:
346-
drawstyle = ds
347-
348338
if drawstyle is None:
349339
drawstyle = 'default'
350340

@@ -1102,39 +1092,6 @@ def set_linewidth(self, w):
11021092
self._dashOffset, self._dashSeq = _scale_dashes(
11031093
self._us_dashOffset, self._us_dashSeq, self._linewidth)
11041094

1105-
def _split_drawstyle_linestyle(self, ls):
1106-
"""
1107-
Split drawstyle from linestyle string.
1108-
1109-
If *ls* is only a drawstyle default to returning a linestyle
1110-
of '-'.
1111-
1112-
Parameters
1113-
----------
1114-
ls : str
1115-
The linestyle to be processed
1116-
1117-
Returns
1118-
-------
1119-
ret_ds : str or None
1120-
If the linestyle string does not contain a drawstyle prefix
1121-
return None, otherwise return it.
1122-
1123-
ls : str
1124-
The linestyle with the drawstyle (if any) stripped.
1125-
"""
1126-
for ds in self.drawStyleKeys: # long names are first in the list
1127-
if ls.startswith(ds):
1128-
cbook.warn_deprecated(
1129-
"3.1", message="Passing the drawstyle with the linestyle "
1130-
"as a single string is deprecated since Matplotlib "
1131-
"%(since)s and support will be removed %(removal)s; "
1132-
"please pass the drawstyle separately using the drawstyle "
1133-
"keyword argument to Line2D or set_drawstyle() method (or "
1134-
"ds/set_ds()).")
1135-
return ds, ls[len(ds):] or '-'
1136-
return None, ls
1137-
11381095
def set_linestyle(self, ls):
11391096
"""
11401097
Set the linestyle of the line.
@@ -1167,10 +1124,6 @@ def set_linestyle(self, ls):
11671124
For examples see :doc:`/gallery/lines_bars_and_markers/linestyles`.
11681125
"""
11691126
if isinstance(ls, str):
1170-
ds, ls = self._split_drawstyle_linestyle(ls)
1171-
if ds is not None:
1172-
self.set_drawstyle(ds)
1173-
11741127
if ls in [' ', '', 'none']:
11751128
ls = 'None'
11761129

0 commit comments

Comments
 (0)