Revision: 6690
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6690&view=rev
Author:   leejjoon
Date:     2008-12-21 04:14:20 +0000 (Sun, 21 Dec 2008)

Log Message:
-----------
Merged revisions 6688-6689 via svnmerge from 
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_98_5_maint

........
  r6688 | leejjoon | 2008-12-20 22:46:05 -0500 (Sat, 20 Dec 2008) | 1 line
  
  fix hatch bug in pdf backend
........
  r6689 | leejjoon | 2008-12-20 23:07:26 -0500 (Sat, 20 Dec 2008) | 1 line
  
  fix dpi dependent offset of Shadow
........

Modified Paths:
--------------
    trunk/matplotlib/CHANGELOG
    trunk/matplotlib/examples/pylab_examples/hatch_demo.py
    trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py
    trunk/matplotlib/lib/matplotlib/patches.py

Property Changed:
----------------
    trunk/matplotlib/


Property changes on: trunk/matplotlib
___________________________________________________________________
Modified: svnmerge-integrated
   - /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6685
   + /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6689

Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG  2008-12-21 04:07:26 UTC (rev 6689)
+++ trunk/matplotlib/CHANGELOG  2008-12-21 04:14:20 UTC (rev 6690)
@@ -1,8 +1,13 @@
+2008-12-20 fix the dpi-dependent offset of Shadow. - JJL
+
+2008-12-20 fix the hatch bug in the pdf backend. minor update
+           in docs and  example - JJL
+
 2008-12-19 Add axes_locator attribute in Axes. Two examples are added.
            - JJL
 
-2008-12-19 Update Axes.legend documnetation. /api/api_changes.rst is also 
-           updated to describe chages in keyword parameters. 
+2008-12-19 Update Axes.legend documnetation. /api/api_changes.rst is also
+           updated to describe chages in keyword parameters.
            Issue a warning if old keyword parameters are used. - JJL
 
 2008-12-18 add new arrow style, a line + filled triangles. -JJL

Modified: trunk/matplotlib/examples/pylab_examples/hatch_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/hatch_demo.py      2008-12-21 
04:07:26 UTC (rev 6689)
+++ trunk/matplotlib/examples/pylab_examples/hatch_demo.py      2008-12-21 
04:14:20 UTC (rev 6690)
@@ -1,18 +1,25 @@
 """
-Hatching (pattern filled polygons) is supported currently on PS
+Hatching (pattern filled polygons) is supported currently on PS and PDF
 backend only.  See the set_patch method in
 http://matplotlib.sf.net/matplotlib.patches.html#Patch
 for details
 """
-import matplotlib
-matplotlib.use('PS')
-from pylab import figure
+import matplotlib.pyplot as plt
 
-fig = figure()
-ax = fig.add_subplot(111)
-bars = ax.bar(range(1,5), range(1,5), color='gray', ecolor='black')
+fig = plt.figure()
+ax1 = fig.add_subplot(121)
+ax1.annotate("Hatch is only supported in the PS and PDF backend", (1, 1),
+             xytext=(0, 5),
+             xycoords="axes fraction", textcoords="offset points", ha="center"
+             )
+ax1.bar(range(1,5), range(1,5), color='gray', ecolor='black', hatch="/")
 
+
+ax2 = fig.add_subplot(122)
+bars = ax2.bar(range(1,5), range(1,5), color='gray', ecolor='black')
+
 patterns = ('/', '+', 'x', '\\')
 for bar, pattern in zip(bars, patterns):
      bar.set_hatch(pattern)
-fig.savefig('hatch4.ps')
+
+plt.show()

Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py     2008-12-21 
04:07:26 UTC (rev 6689)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py     2008-12-21 
04:14:20 UTC (rev 6690)
@@ -942,7 +942,7 @@
     def hatchPattern(self, lst):
         pattern = self.hatchPatterns.get(lst, None)
         if pattern is not None:
-            return pattern[0]
+            return pattern
 
         name = Name('H%d' % self.nextHatch)
         self.nextHatch += 1
@@ -1233,7 +1233,7 @@
 
     def get_image_magnification(self):
         return self.image_dpi/72.0
-            
+
     def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
         # MGDTODO: Support clippath here
         gc = self.new_gc()

Modified: trunk/matplotlib/lib/matplotlib/patches.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/patches.py  2008-12-21 04:07:26 UTC (rev 
6689)
+++ trunk/matplotlib/lib/matplotlib/patches.py  2008-12-21 04:14:20 UTC (rev 
6690)
@@ -247,12 +247,12 @@
 
         CURRENT LIMITATIONS:
 
-        1. Hatching is supported in the PostScript backend only.
+        1. Hatching is supported in the PostScript and the PDF backend only.
 
         2. Hatching is done with solid black lines of width 0.
 
 
-        ACCEPTS: [ '/' | '\\' | '|' | '-' | '#' | 'x' ]
+        ACCEPTS: [ '/' | '\\' | '|' | '-' | '#' | 'x' ] (ps & pdf backend only)
         """
         self._hatch = h
 
@@ -373,7 +373,7 @@
         self.patch = patch
         self.props = props
         self._ox, self._oy = ox, oy
-        self._update_transform()
+        self._shadow_transform = transforms.Affine2D()
         self._update()
     __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd
 
@@ -391,20 +391,20 @@
             self.set_facecolor((r,g,b,0.5))
             self.set_edgecolor((r,g,b,0.5))
 
-    def _update_transform(self):
-        self._shadow_transform = transforms.Affine2D().translate(self._ox, 
self._oy)
+    def _update_transform(self, renderer):
+        ox = renderer.points_to_pixels(self._ox)
+        oy = renderer.points_to_pixels(self._oy)
+        self._shadow_transform.clear().translate(ox, oy)
 
     def _get_ox(self):
         return self._ox
     def _set_ox(self, ox):
         self._ox = ox
-        self._update_transform()
 
     def _get_oy(self):
         return self._oy
     def _set_oy(self, oy):
         self._oy = oy
-        self._update_transform()
 
     def get_path(self):
         return self.patch.get_path()
@@ -412,6 +412,10 @@
     def get_patch_transform(self):
         return self.patch.get_patch_transform() + self._shadow_transform
 
+    def draw(self, renderer):
+        self._update_transform(renderer)
+        Patch.draw(self, renderer)
+
 class Rectangle(Patch):
     """
     Draw a rectangle with lower left at *xy* = (*x*, *y*) with


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

------------------------------------------------------------------------------
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to