From: <jo...@us...> - 2009-02-02 19:35:47
|
Revision: 6868 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6868&view=rev Author: jouni Date: 2009-02-02 19:35:43 +0000 (Mon, 02 Feb 2009) Log Message: ----------- Reduce number of marker objects in pdf output Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009-02-02 17:58:48 UTC (rev 6867) +++ trunk/matplotlib/CHANGELOG 2009-02-02 19:35:43 UTC (rev 6868) @@ -1,3 +1,5 @@ +2009-02-02 Reduce number of marker XObjects in pdf output - JKS + 2009-02-02 Change default resolution on polar plot to 1 - MGD 2009-02-02 Avoid malloc errors in ttconv for fonts that don't have Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2009-02-02 17:58:48 UTC (rev 6867) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2009-02-02 19:35:43 UTC (rev 6868) @@ -1109,26 +1109,28 @@ def markerObject(self, path, trans, fillp, lw): """Return name of a marker XObject representing the given path.""" - key = (path, trans, fillp is not None, lw) + pathops = self.pathOperations(path, trans) + key = (tuple(pathops), bool(fillp)) result = self.markers.get(key) if result is None: name = Name('M%d' % len(self.markers)) ob = self.reserveObject('marker %d' % len(self.markers)) - self.markers[key] = (name, ob, path, trans, fillp, lw) + bbox = path.get_extents(trans) + self.markers[key] = [name, ob, bbox, lw] else: + if result[-1] < lw: + result[-1] = lw name = result[0] return name def writeMarkers(self): - for tup in self.markers.values(): - name, object, path, trans, fillp, lw = tup - bbox = path.get_extents(trans) + for (pathops, fillp),(name, ob, bbox, lw) in self.markers.iteritems(): bbox = bbox.padded(lw * 0.5) self.beginStream( - object.id, None, + ob.id, None, {'Type': Name('XObject'), 'Subtype': Name('Form'), 'BBox': list(bbox.extents) }) - self.writePath(path, trans) + self.output(*pathops) if fillp: self.output(Op.fill_stroke) else: @@ -1280,10 +1282,17 @@ def draw_path(self, gc, path, transform, rgbFace=None): self.check_gc(gc, rgbFace) - stream = self.file.writePath(path, transform, rgbFace is None) + self.file.writePath(path, transform, rgbFace is None) self.file.output(self.gc.paint()) def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None): + # For simple paths or small numbers of markers, don't bother + # making an XObject + if len(path) * len(marker_path) <= 10: + RendererBase.draw_markers(self, gc, marker_path, marker_trans, + path, trans, rgbFace) + return + self.check_gc(gc, rgbFace) fillp = rgbFace is not None This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |