|
7 | 7 | from . import files |
8 | 8 | from . import path as mypath |
9 | 9 | from .util import get_legend_text, has_legend, transform_to_data_coordinates |
| 10 | +from ._markers import _mpl_marker2pgfp_marker |
10 | 11 |
|
11 | 12 |
|
12 | 13 | def draw_line2d(data, obj): |
@@ -123,77 +124,6 @@ def draw_linecollection(data, obj): |
123 | 124 | return data, content |
124 | 125 |
|
125 | 126 |
|
126 | | -# for matplotlib markers, see: http://matplotlib.org/api/markers_api.html |
127 | | -_MP_MARKER2PGF_MARKER = { |
128 | | - ".": "*", # point |
129 | | - "o": "o", # circle |
130 | | - "+": "+", # plus |
131 | | - "x": "x", # x |
132 | | - "None": None, |
133 | | - " ": None, |
134 | | - "": None, |
135 | | -} |
136 | | - |
137 | | -# the following markers are only available with PGF's plotmarks library |
138 | | -_MP_MARKER2PLOTMARKS = { |
139 | | - "v": ("triangle", "rotate=180"), # triangle down |
140 | | - "1": ("triangle", "rotate=180"), |
141 | | - "^": ("triangle", None), # triangle up |
142 | | - "2": ("triangle", None), |
143 | | - "<": ("triangle", "rotate=270"), # triangle left |
144 | | - "3": ("triangle", "rotate=270"), |
145 | | - ">": ("triangle", "rotate=90"), # triangle right |
146 | | - "4": ("triangle", "rotate=90"), |
147 | | - "s": ("square", None), |
148 | | - "p": ("pentagon", None), |
149 | | - "*": ("asterisk", None), |
150 | | - "h": ("star", None), # hexagon 1 |
151 | | - "H": ("star", None), # hexagon 2 |
152 | | - "d": ("diamond", None), # diamond |
153 | | - "D": ("diamond", None), # thin diamond |
154 | | - "|": ("|", None), # vertical line |
155 | | - "_": ("-", None), # horizontal line |
156 | | -} |
157 | | - |
158 | | - |
159 | | -def _mpl_marker2pgfp_marker(data, mpl_marker, marker_face_color): |
160 | | - """Translates a marker style of matplotlib to the corresponding style |
161 | | - in PGFPlots. |
162 | | - """ |
163 | | - # try default list |
164 | | - try: |
165 | | - pgfplots_marker = _MP_MARKER2PGF_MARKER[mpl_marker] |
166 | | - except KeyError: |
167 | | - pass |
168 | | - else: |
169 | | - if (marker_face_color is not None) and pgfplots_marker == "o": |
170 | | - pgfplots_marker = "*" |
171 | | - data["tikz libs"].add("plotmarks") |
172 | | - marker_options = None |
173 | | - return (data, pgfplots_marker, marker_options) |
174 | | - |
175 | | - # try plotmarks list |
176 | | - try: |
177 | | - data["tikz libs"].add("plotmarks") |
178 | | - pgfplots_marker, marker_options = _MP_MARKER2PLOTMARKS[mpl_marker] |
179 | | - except KeyError: |
180 | | - # There's no equivalent for the pixel marker (,) in Pgfplots. |
181 | | - pass |
182 | | - else: |
183 | | - if ( |
184 | | - marker_face_color is not None |
185 | | - and ( |
186 | | - not isinstance(marker_face_color, str) |
187 | | - or marker_face_color.lower() != "none" |
188 | | - ) |
189 | | - and pgfplots_marker not in ["|", "-", "asterisk", "star"] |
190 | | - ): |
191 | | - pgfplots_marker += "*" |
192 | | - return (data, pgfplots_marker, marker_options) |
193 | | - |
194 | | - return data, None, None |
195 | | - |
196 | | - |
197 | 127 | def _marker( |
198 | 128 | obj, |
199 | 129 | data, |
@@ -227,8 +157,7 @@ def _marker( |
227 | 157 | ) |
228 | 158 |
|
229 | 159 | mark_options = ["solid"] |
230 | | - if extra_mark_options: |
231 | | - mark_options.append(extra_mark_options) |
| 160 | + mark_options += extra_mark_options |
232 | 161 | if marker_face_color is None or ( |
233 | 162 | isinstance(marker_face_color, str) and marker_face_color == "none" |
234 | 163 | ): |
|
0 commit comments