MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _iter_collection

Method _iter_collection

lib/matplotlib/backend_bases.py:346–428  ·  view source on GitHub ↗

Helper method (along with `_iter_collection_raw_paths`) to implement `draw_path_collection` in a memory-efficient manner. This method yields all of the path, offset and graphics context combinations to draw the path collection. The caller should already hav

(self, gc, path_ids, offsets, offset_trans, facecolors,
                         edgecolors, linewidths, linestyles,
                         antialiaseds, urls, offset_position, *, hatchcolors)

Source from the content-addressed store, hash-verified

344 return (N + Npath_ids - 1) // Npath_ids
345
346 def _iter_collection(self, gc, path_ids, offsets, offset_trans, facecolors,
347 edgecolors, linewidths, linestyles,
348 antialiaseds, urls, offset_position, *, hatchcolors):
349 """
350 Helper method (along with `_iter_collection_raw_paths`) to implement
351 `draw_path_collection` in a memory-efficient manner.
352
353 This method yields all of the path, offset and graphics context
354 combinations to draw the path collection. The caller should already
355 have looped over the results of `_iter_collection_raw_paths` to draw
356 this collection.
357
358 The arguments should be the same as that passed into
359 `draw_path_collection`, with the exception of *path_ids*, which is a
360 list of arbitrary objects that the backend will use to reference one of
361 the paths created in the `_iter_collection_raw_paths` stage.
362
363 Each yielded result is of the form::
364
365 xo, yo, path_id, gc, rgbFace
366
367 where *xo*, *yo* is an offset; *path_id* is one of the elements of
368 *path_ids*; *gc* is a graphics context and *rgbFace* is a color to
369 use for filling the path.
370 """
371 Npaths = len(path_ids)
372 Noffsets = len(offsets)
373 N = max(Npaths, Noffsets)
374 Nfacecolors = len(facecolors)
375 Nedgecolors = len(edgecolors)
376 Nhatchcolors = len(hatchcolors)
377 Nlinewidths = len(linewidths)
378 Nlinestyles = len(linestyles)
379 Nurls = len(urls)
380
381 if (Nfacecolors == 0 and Nedgecolors == 0 and Nhatchcolors == 0) or Npaths == 0:
382 return
383
384 gc0 = self.new_gc()
385 gc0.copy_properties(gc)
386
387 def cycle_or_default(seq, default=None):
388 # Cycle over *seq* if it is not empty; else always yield *default*.
389 return (itertools.cycle(seq) if len(seq)
390 else itertools.repeat(default))
391
392 pathids = cycle_or_default(path_ids)
393 toffsets = cycle_or_default(offset_trans.transform(offsets), (0, 0))
394 fcs = cycle_or_default(facecolors)
395 ecs = cycle_or_default(edgecolors)
396 hcs = cycle_or_default(hatchcolors)
397 lws = cycle_or_default(linewidths)
398 lss = cycle_or_default(linestyles)
399 aas = cycle_or_default(antialiaseds)
400 urls = cycle_or_default(urls)
401
402 if Nedgecolors == 0:
403 gc0.set_linewidth(0.0)

Callers 6

draw_path_collectionMethod · 0.95
checkFunction · 0.95
drawMethod · 0.80
draw_path_collectionMethod · 0.80
draw_path_collectionMethod · 0.80
draw_path_collectionMethod · 0.80

Calls 11

new_gcMethod · 0.95
set_hatch_colorMethod · 0.80
copy_propertiesMethod · 0.45
transformMethod · 0.45
set_linewidthMethod · 0.45
set_dashesMethod · 0.45
to_rgbaMethod · 0.45
set_foregroundMethod · 0.45
set_antialiasedMethod · 0.45
set_urlMethod · 0.45
restoreMethod · 0.45

Tested by 1

checkFunction · 0.76