@@ -24,12 +24,10 @@ def draw_patch(data, obj):
24
24
elif isinstance (obj , mpl .patches .Ellipse ):
25
25
# ellipse specialization
26
26
return _draw_ellipse (data , obj , draw_options )
27
+ else :
28
+ # regular patch
29
+ return _draw_polygon (data , obj , draw_options )
27
30
28
- # regular patch
29
- data , path_command , _ , _ = mypath .draw_path (
30
- data , obj .get_path (), draw_options = draw_options
31
- )
32
- return data , path_command
33
31
34
32
def _is_in_legend (obj ):
35
33
label = obj .get_label ()
@@ -112,7 +110,14 @@ def draw_patchcollection(data, obj):
112
110
113
111
return data , content
114
112
113
+ @legendimage
114
+ def _draw_polygon (data , obj , draw_options ):
115
+ data , content , _ , is_area = mypath .draw_path (
116
+ data , obj .get_path (), draw_options = draw_options
117
+ )
118
+ legend_type = "area legend" if is_area else "line legend"
115
119
120
+ return data , content , legend_type
116
121
117
122
118
123
def _draw_rectangle (data , obj , draw_options ):
@@ -158,6 +163,7 @@ def _draw_rectangle(data, obj, draw_options):
158
163
return data , cont
159
164
160
165
166
+ @legendimage
161
167
def _draw_ellipse (data , obj , draw_options ):
162
168
"""Return the PGFPlots code for ellipses.
163
169
"""
@@ -180,17 +186,19 @@ def _draw_ellipse(data, obj, draw_options):
180
186
+ ff
181
187
+ " and "
182
188
+ ff
183
- + ");\n "
189
+ + ");"
184
190
).format ("," .join (draw_options ), x , y , 0.5 * obj .width , 0.5 * obj .height )
185
- return data , cont
186
191
192
+ return data , cont , "area legend"
187
193
194
+
195
+ @legendimage
188
196
def _draw_circle (data , obj , draw_options ):
189
197
"""Return the PGFPlots code for circles.
190
198
"""
191
199
x , y = obj .center
192
200
ff = data ["float format" ]
193
- cont = ("\\ draw[{}] (axis cs:" + ff + "," + ff + ") circle (" + ff + ");\n " ).format (
201
+ cont = ("\\ draw[{}] (axis cs:" + ff + "," + ff + ") circle (" + ff + ");" ).format (
194
202
"," .join (draw_options ), x , y , obj .get_radius ()
195
203
)
196
- return data , cont
204
+ return data , cont , "area legend"
0 commit comments