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

Function _draw_list_compositing_images

lib/matplotlib/image.py:115–159  ·  view source on GitHub ↗

Draw a sorted list of artists, compositing images into a single image where possible. For internal Matplotlib use only: It is here to reduce duplication between `Figure.draw` and `Axes.draw`, but otherwise should not be generally useful.

(
        renderer, parent, artists, suppress_composite=None)

Source from the content-addressed store, hash-verified

113
114
115def _draw_list_compositing_images(
116 renderer, parent, artists, suppress_composite=None):
117 """
118 Draw a sorted list of artists, compositing images into a single
119 image where possible.
120
121 For internal Matplotlib use only: It is here to reduce duplication
122 between `Figure.draw` and `Axes.draw`, but otherwise should not be
123 generally useful.
124 """
125 has_images = any(isinstance(x, _ImageBase) for x in artists)
126
127 # override the renderer default if suppressComposite is not None
128 not_composite = (suppress_composite if suppress_composite is not None
129 else renderer.option_image_nocomposite())
130
131 if not_composite or not has_images:
132 for a in artists:
133 a.draw(renderer)
134 else:
135 # Composite any adjacent images together
136 image_group = []
137 mag = renderer.get_image_magnification()
138
139 def flush_images():
140 if len(image_group) == 1:
141 image_group[0].draw(renderer)
142 elif len(image_group) > 1:
143 data, l, b = composite_images(image_group, renderer, mag)
144 if data.size != 0:
145 gc = renderer.new_gc()
146 gc.set_clip_rectangle(parent.bbox)
147 gc.set_clip_path(parent.get_clip_path())
148 renderer.draw_image(gc, round(l), round(b), data)
149 gc.restore()
150 del image_group[:]
151
152 for a in artists:
153 if (isinstance(a, _ImageBase) and a.can_composite() and
154 a.get_clip_on() and not a.get_clip_path()):
155 image_group.append(a)
156 else:
157 flush_images()
158 a.draw(renderer)
159 flush_images()
160
161
162def _resample(

Callers

nothing calls this directly

Calls 7

flush_imagesFunction · 0.85
can_compositeMethod · 0.80
get_clip_onMethod · 0.80
drawMethod · 0.45
get_clip_pathMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…