From 6fb37980b85d371225f4e4bf1db6166e17cef92b Mon Sep 17 00:00:00 2001 From: Yannick Copin Date: Wed, 18 Mar 2015 12:26:25 +0100 Subject: [PATCH] Use traditional linestyle shortcuts in setter '-'=solid, '--'=dashed, ':'=dotted, '-.'=dashdot. The conversion is done on the fly, no other changes needed in the code. --- lib/matplotlib/backend_bases.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 02f67136e7d0..4511364ff8a0 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -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.: @@ -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):