34
34
35
35
def _process_plot_format (fmt ):
36
36
"""
37
- Process a MATLAB style color/line style format string. Return a
38
- (*linestyle*, *color*) tuple as a result of the processing. Default
39
- values are ('-', 'b'). Example format strings include:
37
+ Convert a MATLAB style color/line style format string to a (*linestyle*,
38
+ *marker*, *color*) tuple.
39
+
40
+ Example format strings include:
40
41
41
42
* 'ko': black circles
42
43
* '.b': blue dots
@@ -73,24 +74,16 @@ def _process_plot_format(fmt):
73
74
except ValueError :
74
75
pass # No, not just a color.
75
76
76
- # handle the multi char special cases and strip them from the
77
- # string
78
- if fmt .find ('--' ) >= 0 :
79
- linestyle = '--'
80
- fmt = fmt .replace ('--' , '' )
81
- if fmt .find ('-.' ) >= 0 :
82
- linestyle = '-.'
83
- fmt = fmt .replace ('-.' , '' )
84
- if fmt .find (' ' ) >= 0 :
85
- linestyle = 'None'
86
- fmt = fmt .replace (' ' , '' )
87
-
88
- chars = [c for c in fmt ]
89
-
90
77
i = 0
91
- while i < len (chars ):
92
- c = chars [i ]
93
- if c in mlines .lineStyles :
78
+ while i < len (fmt ):
79
+ c = fmt [i ]
80
+ if fmt [i :i + 2 ] in mlines .lineStyles : # First, the two-char styles.
81
+ if linestyle is not None :
82
+ raise ValueError (
83
+ 'Illegal format string "%s"; two linestyle symbols' % fmt )
84
+ linestyle = fmt [i :i + 2 ]
85
+ i += 1
86
+ elif c in mlines .lineStyles :
94
87
if linestyle is not None :
95
88
raise ValueError (
96
89
'Illegal format string "%s"; two linestyle symbols' % fmt )
@@ -105,8 +98,8 @@ def _process_plot_format(fmt):
105
98
raise ValueError (
106
99
'Illegal format string "%s"; two color symbols' % fmt )
107
100
color = c
108
- elif c == 'C' and i < len (chars ) - 1 :
109
- color_cycle_number = int (chars [i + 1 ])
101
+ elif c == 'C' and i < len (fmt ) - 1 :
102
+ color_cycle_number = int (fmt [i + 1 ])
110
103
color = mcolors .to_rgba ("C{}" .format (color_cycle_number ))
111
104
i += 1
112
105
else :
@@ -117,9 +110,9 @@ def _process_plot_format(fmt):
117
110
if linestyle is None and marker is None :
118
111
linestyle = rcParams ['lines.linestyle' ]
119
112
if linestyle is None :
120
- linestyle = 'None '
113
+ linestyle = 'none '
121
114
if marker is None :
122
- marker = 'None '
115
+ marker = 'none '
123
116
124
117
return linestyle , marker , color
125
118
0 commit comments