Skip to content

Use traditional linestyle shortcuts #4241

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

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 7 additions & 1 deletion lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,8 @@ def set_linewidth(self, w):
def set_linestyle(self, style):
"""
Set the linestyle to be one of ('solid', 'dashed', 'dashdot',
'dotted'). One may specify customized dash styles by providing
'dotted') or traditional shortcuts ('-', '--', '-.', ':').
One may specify customized dash styles by providing
a tuple of (offset, dash pairs). For example, the predefiend
linestyles have following values.:

Expand All @@ -1045,6 +1046,11 @@ def set_linestyle(self, style):
'dotted' : (0, (1.0, 3.0)),
"""

# Conversion from usual shortcuts
conversion = {'-': 'solid', '--': 'dashed',
':': 'dotted', '-.': 'dashdot'}
style = conversion.get(style, style)

if style in self.dashd:
offset, dashes = self.dashd[style]
elif isinstance(style, tuple):
Expand Down