@@ -167,32 +167,33 @@ def _draw_mpl_lwpoly(self, gc, path, transform, obj):
167167
168168 # clip the polygon if clip rectangle present
169169
170- if isinstance (vertices [0 ][0 ], float or np .float64 ):
171- vertices = self ._clip_mpl (gc , vertices , obj = obj )
172-
173- else :
174- vertices = [self ._clip_mpl (gc , points , obj = obj ) for points in vertices ]
170+ if len (vertices ) > 0 :
171+ if isinstance (vertices [0 ][0 ], float or np .float64 ):
172+ vertices = self ._clip_mpl (gc , vertices , obj = obj )
175173
176- # if vertices.
177- if len (vertices ) == 0 :
178- entity = None
174+ else :
175+ vertices = [self ._clip_mpl (gc , points , obj = obj ) for points in vertices ]
179176
180- else :
181- if isinstance (vertices [0 ][0 ], float or np .float64 ):
182- if vertices [0 ][0 ] != 0 :
183- entity = self .modelspace .add_lwpolyline (
184- points = vertices , close = False , dxfattribs = dxfattribs
185- ) # set close to false because it broke some arrows
186- else :
187- entity = None
177+ # if vertices.
178+ if len (vertices ) == 0 :
179+ entity = None
188180
189181 else :
190- entity = [
191- self .modelspace .add_lwpolyline (
192- points = points , close = False , dxfattribs = dxfattribs
193- )
194- for points in vertices
195- ] # set close to false because it broke some arrows
182+ if isinstance (vertices [0 ][0 ], float or np .float64 ):
183+ if vertices [0 ][0 ] != 0 :
184+ entity = self .modelspace .add_lwpolyline (
185+ points = vertices , close = False , dxfattribs = dxfattribs
186+ ) # set close to false because it broke some arrows
187+ else :
188+ entity = None
189+
190+ else :
191+ entity = [
192+ self .modelspace .add_lwpolyline (
193+ points = points , close = False , dxfattribs = dxfattribs
194+ )
195+ for points in vertices
196+ ] # set close to false because it broke some arrows
196197 return entity
197198
198199 def _draw_mpl_line2d (self , gc , path , transform ):
@@ -311,7 +312,7 @@ def draw_path_collection(
311312 paths ,
312313 all_transforms ,
313314 offsets ,
314- offsetTrans ,
315+ offset_trans ,
315316 facecolors ,
316317 edgecolors ,
317318 linewidths ,
@@ -320,17 +321,14 @@ def draw_path_collection(
320321 urls ,
321322 offset_position ,
322323 ):
323- if self ._groupd [- 1 ] == "PolyCollection" :
324- # Behandle PolyCollection som en samling av 'patch'-objekter
325- for path in paths :
326- # Kombiner master_transform med path_transform for hver path
327- combined_transform = master_transform
328- # Her kan du velge å bruke eller tilpasse rgbFace basert på facecolors, hvis det er relevant
329- if facecolors .size :
330- rgbFace = facecolors [0 ] if facecolors is not None else None
331- else :
332- rgbFace = None
333- self ._draw_mpl_patch (gc , path , combined_transform , rgbFace )
324+ for path in paths :
325+ combined_transform = master_transform
326+ if facecolors .size :
327+ rgbFace = facecolors [0 ] if facecolors is not None else None
328+ else :
329+ rgbFace = None
330+ # Draw each path as a filled patch
331+ self ._draw_mpl_patch (gc , path , combined_transform , rgbFace = rgbFace )
334332
335333 def draw_path (self , gc , path , transform , rgbFace = None ):
336334 # print('\nEntered ###DRAW_PATH###')
0 commit comments