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

Skip to content

Commit 18d19b7

Browse files
committed
Axes.draw rearranged to support rasterization
svn path=/trunk/matplotlib/; revision=8022
1 parent cd96916 commit 18d19b7

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

lib/matplotlib/axes.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import matplotlib.ticker as mticker
3131
import matplotlib.transforms as mtransforms
3232

33+
from operator import itemgetter
34+
3335
iterable = cbook.iterable
3436
is_string_like = cbook.is_string_like
3537
is_sequence_of_strings = cbook.is_sequence_of_strings
@@ -1698,11 +1700,22 @@ def draw(self, renderer=None, inframe=False):
16981700
artists.extend(self.spines.itervalues())
16991701

17001702

1703+
17011704
dsu = [ (a.zorder, a) for a in artists
17021705
if not a.get_animated() ]
1703-
dsu.sort(key=lambda x: x[0])
17041706

17051707

1708+
# add images to dsu if the backend support compositing.
1709+
# otherwise, does the manaul compositing without adding images to dsu.
1710+
if len(self.images)<=1 or renderer.option_image_nocomposite():
1711+
dsu.extend([(im.zorder, im) for im in self.images])
1712+
_do_composite = False
1713+
else:
1714+
_do_composite = True
1715+
1716+
1717+
dsu.sort(key=itemgetter(0))
1718+
17061719
# rasterize artists with negative zorder
17071720
# if the minimum zorder is negative, start rasterization
17081721
rasterization_zorder = self._rasterization_zorder
@@ -1719,11 +1732,7 @@ def draw(self, renderer=None, inframe=False):
17191732
if self.axison and self._frameon:
17201733
self.patch.draw(renderer)
17211734

1722-
if len(self.images)<=1 or renderer.option_image_nocomposite():
1723-
for im in self.images:
1724-
dsu.append( (im.zorder, im) )
1725-
dsu.sort(key=lambda x: x[0]) # re-sort with images now
1726-
else:
1735+
if _do_composite:
17271736
# make a composite image blending alpha
17281737
# list of (mimage.Image, ox, oy)
17291738

0 commit comments

Comments
 (0)