Revision: 5879
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5879&view=rev
Author:   jdh2358
Date:     2008-07-25 23:45:01 +0000 (Fri, 25 Jul 2008)

Log Message:
-----------
fix for ps renderer dpi/imagedpi confusion

Modified Paths:
--------------
    trunk/matplotlib/examples/pylab_examples/image_demo.py
    trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
    trunk/matplotlib/lib/matplotlib/collections.py
    trunk/matplotlib/lib/matplotlib/text.py

Modified: trunk/matplotlib/examples/pylab_examples/image_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/image_demo.py      2008-07-25 
23:22:26 UTC (rev 5878)
+++ trunk/matplotlib/examples/pylab_examples/image_demo.py      2008-07-25 
23:45:01 UTC (rev 5879)
@@ -14,5 +14,6 @@
 im = plt.imshow(Z, interpolation='bilinear', cmap=cm.gray,
                 origin='lower', extent=[-3,3,-3,3])
 
+plt.savefig('test.ps', dpi=300)
 plt.show()
 

Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py      2008-07-25 
23:22:26 UTC (rev 5878)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py      2008-07-25 
23:45:01 UTC (rev 5879)
@@ -126,7 +126,12 @@
     fontd = maxdict(50)
     afmfontd = maxdict(50)
 
-    def __init__(self, width, height, pswriter, dpi=72):
+    def __init__(self, width, height, pswriter, imagedpi=72):
+        """
+        Although postscript itself is dpi independent, we need to
+        imform the image code about a requested dpi to generate high
+        res images and them scale them before embeddin them
+        """
         RendererBase.__init__(self)
         self.width = width
         self.height = height
@@ -134,7 +139,7 @@
         if rcParams['text.usetex']:
             self.textcnt = 0
             self.psfrag = []
-        self.dpi = dpi
+        self.imagedpi = imagedpi
 
         # current renderer state (None=uninitialised)
         self.color = None
@@ -145,7 +150,7 @@
         self.fontname = None
         self.fontsize = None
         self.hatch = None
-        self.image_magnification = dpi/72.0
+        self.image_magnification = imagedpi/72.0
         self._clip_paths = {}
         self._path_collection_id = 0
 
@@ -857,15 +862,15 @@
         else: raise RuntimeError('Orientation must be "portrait" or 
"landscape"')
 
         self.figure.set_dpi(72) # Override the dpi kwarg
-        dpi = kwargs.get("dpi", 72)
+        imagedpi = kwargs.get("dpi", 72)
         facecolor = kwargs.get("facecolor", "w")
         edgecolor = kwargs.get("edgecolor", "w")
 
         if rcParams['text.usetex']:
-            self._print_figure_tex(outfile, format, dpi, facecolor, edgecolor,
+            self._print_figure_tex(outfile, format, imagedpi, facecolor, 
edgecolor,
                                    orientation, isLandscape, papertype)
         else:
-            self._print_figure(outfile, format, dpi, facecolor, edgecolor,
+            self._print_figure(outfile, format, imagedpi, facecolor, edgecolor,
                                orientation, isLandscape, papertype)
 
     def _print_figure(self, outfile, format, dpi=72, facecolor='w', 
edgecolor='w',
@@ -939,7 +944,7 @@
         self.figure.set_edgecolor(edgecolor)
 
         self._pswriter = StringIO()
-        renderer = RendererPS(width, height, self._pswriter, dpi=dpi)
+        renderer = RendererPS(width, height, self._pswriter, imagedpi=dpi)
         self.figure.draw(renderer)
 
         self.figure.set_facecolor(origfacecolor)
@@ -1050,7 +1055,7 @@
         self.figure.set_edgecolor(edgecolor)
 
         self._pswriter = StringIO()
-        renderer = RendererPS(width, height, self._pswriter, dpi=dpi)
+        renderer = RendererPS(width, height, self._pswriter, imagedpi=dpi)
         self.figure.draw(renderer)
 
         self.figure.set_facecolor(origfacecolor)

Modified: trunk/matplotlib/lib/matplotlib/collections.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/collections.py      2008-07-25 23:22:26 UTC 
(rev 5878)
+++ trunk/matplotlib/lib/matplotlib/collections.py      2008-07-25 23:45:01 UTC 
(rev 5879)
@@ -222,7 +222,7 @@
         """
         Set the offsets for the collection.  *offsets* can be a scalar
         or a sequence.
-        
+
         ACCEPTS: float or sequence of floats
         """
         offsets = np.asarray(offsets, np.float_)
@@ -603,7 +603,7 @@
         if self._sizes is not None:
             self._transforms = [
                 transforms.Affine2D().scale(
-                    (np.sqrt(x) * renderer.dpi / 72.0))
+                    (np.sqrt(x) * self.figure.dpi / 72.0))
                 for x in self._sizes]
         return Collection.draw(self, renderer)
 
@@ -680,7 +680,7 @@
         # in points^2
         self._transforms = [
             transforms.Affine2D().rotate(-self._rotation).scale(
-                (np.sqrt(x) * renderer.dpi / 72.0) / np.sqrt(np.pi))
+                (np.sqrt(x) * self.figure.dpi / 72.0) / np.sqrt(np.pi))
             for x in self._sizes]
         return Collection.draw(self, renderer)
 
@@ -877,7 +877,7 @@
         # in points^2
         self._transforms = [
             transforms.Affine2D().scale(
-                (np.sqrt(x) * renderer.dpi / 72.0) / np.sqrt(np.pi))
+                (np.sqrt(x) * self.figure.dpi / 72.0) / np.sqrt(np.pi))
             for x in self._sizes]
         return Collection.draw(self, renderer)
 

Modified: trunk/matplotlib/lib/matplotlib/text.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/text.py     2008-07-25 23:22:26 UTC (rev 
5878)
+++ trunk/matplotlib/lib/matplotlib/text.py     2008-07-25 23:45:01 UTC (rev 
5879)
@@ -400,7 +400,7 @@
         return (x, y, self._text, self._color,
                 self._verticalalignment, self._horizontalalignment,
                 hash(self._fontproperties), self._rotation,
-                self._renderer.dpi, id(self._renderer)
+                self.figure.dpi, id(self._renderer)
                 )
 
     def get_text(self):


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to