Skip to content

Deprecate passing drawstyle with linestyle as single string. #12442

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 1 commit into from
Oct 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions doc/api/api_changes/2018-10-08-AL-deprecations.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Passing a Line2D's drawstyle together with the linestyle is deprecated
``````````````````````````````````````````````````````````````````````

Instead of ``plt.plot(..., linestyle="steps--")``, use ``plt.plot(...,
linestyle="--", drawstyle="steps")``. ``ds`` is now an alias for ``drawstyle``.
3 changes: 1 addition & 2 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2047,8 +2047,7 @@ def step(self, x, y, *args, where='pre', **kwargs):
if where not in ('pre', 'post', 'mid'):
raise ValueError("'where' argument to step must be "
"'pre', 'post' or 'mid'")
kwargs['linestyle'] = 'steps-' + where + kwargs.get('linestyle', '')

kwargs['drawstyle'] = 'steps-' + where
return self.plot(x, y, *args, **kwargs)

@_preprocess_data(replace_names=["x", "left",
Expand Down
8 changes: 8 additions & 0 deletions lib/matplotlib/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def _slice_or_none(in_v, slc):
@cbook._define_aliases({
"antialiased": ["aa"],
"color": ["c"],
"drawstyle": ["ds"],
"linestyle": ["ls"],
"linewidth": ["lw"],
"markeredgecolor": ["mec"],
Expand Down Expand Up @@ -1133,6 +1134,13 @@ def _split_drawstyle_linestyle(self, ls):
"""
for ds in self.drawStyleKeys: # long names are first in the list
if ls.startswith(ds):
cbook.warn_deprecated(
"3.1", message="Passing the drawstyle with the linestyle "
"as a single string is deprecated since Matplotlib "
"%(since)s and support will be removed %(removal)s; "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed in

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%(removal)s includes it.

"please pass the drawstyle separately using the drawstyle "
"keyword argument to Line2D or set_drawstyle() method (or "
"ds/set_ds()).")
return ds, ls[len(ds):] or '-'
return None, ls

Expand Down