Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8d638e0

Browse files
committed
added a note to self
svn path=/trunk/matplotlib/; revision=5620
1 parent 416d1df commit 8d638e0

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

lib/matplotlib/figure.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,11 @@ class Figure(Artist):
211211
212212
*figurePatch*
213213
a :class:`matplotlib.patches.Rectangle` instance
214-
214+
*suppressComposite
215+
for multiple figure images, the figure will make composite
216+
images depending on the renderer option_image_nocomposite
217+
function. If suppressComposite is True|False, this will
218+
override the renderer
215219
"""
216220

217221
def __str__(self):
@@ -278,7 +282,6 @@ def __init__(self,
278282
self._axstack = Stack() # maintain the current axes
279283
self.axes = []
280284
self.clf()
281-
282285
self._cachedRenderer = None
283286

284287
def _get_dpi(self):
@@ -328,6 +331,7 @@ def autofmt_xdate(self, bottom=0.2, rotation=30, ha='right'):
328331
def get_children(self):
329332
'get a list of artists contained in the figure'
330333
children = [self.figurePatch]
334+
children.extend(self.artists)
331335
children.extend(self.axes)
332336
children.extend(self.lines)
333337
children.extend(self.patches)
@@ -755,7 +759,7 @@ def clf(self):
755759
"""
756760
Clear the figure
757761
"""
758-
762+
self.suppressComposite = None
759763
self.callbacks = cbook.CallbackRegistry(('dpi_changed', ))
760764

761765
for ax in tuple(self.axes): # Iterate over the copy.
@@ -767,6 +771,7 @@ def clf(self):
767771
toolbar.update()
768772
self._axstack.clear()
769773
self._seen = {}
774+
self.artists = []
770775
self.lines = []
771776
self.patches = []
772777
self.texts=[]
@@ -791,16 +796,23 @@ def draw(self, renderer):
791796

792797
if self.frameon: self.figurePatch.draw(renderer)
793798

799+
# todo: respect zorder
794800
for p in self.patches: p.draw(renderer)
795801
for l in self.lines: l.draw(renderer)
796-
797-
if len(self.images)<=1 or renderer.option_image_nocomposite() or not allequal([im.origin for im in self.images]):
802+
for a in self.artists: a.draw(renderer)
803+
804+
# override the renderer default if self.suppressComposite
805+
# is not None
806+
composite = renderer.option_image_nocomposite()
807+
if self.suppressComposite is not None:
808+
composite = self.suppressComposite
809+
810+
if len(self.images)<=1 or composite or not allequal([im.origin for im in self.images]):
798811
for im in self.images:
799812
im.draw(renderer)
800813
else:
801814
# make a composite image blending alpha
802815
# list of (_image.Image, ox, oy)
803-
804816
mag = renderer.get_image_magnification()
805817
ims = [(im.make_image(mag), im.ox*mag, im.oy*mag)
806818
for im in self.images]

lib/matplotlib/image.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,9 @@ def make_image(self, magnification=1.0):
656656

657657
def draw(self, renderer, *args, **kwargs):
658658
if not self.get_visible(): return
659+
# todo: we should be able to do some cacheing here
659660
im = self.make_image()
661+
660662
renderer.draw_image(round(self.ox), round(self.oy), im, self.figure.bbox,
661663
*self.get_transformed_clip_path_and_affine())
662664

0 commit comments

Comments
 (0)