Revision: 4785
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4785&view=rev
Author:   jdh2358
Date:     2007-12-21 08:22:42 -0800 (Fri, 21 Dec 2007)

Log Message:
-----------
added unit support to arc

Modified Paths:
--------------
    trunk/matplotlib/API_CHANGES
    trunk/matplotlib/CODING_GUIDE
    trunk/matplotlib/examples/units/ellipse_with_units.py
    trunk/matplotlib/lib/matplotlib/mlab.py
    trunk/matplotlib/lib/matplotlib/patches.py
    trunk/matplotlib/unit/ellipse_large.py

Modified: trunk/matplotlib/API_CHANGES
===================================================================
--- trunk/matplotlib/API_CHANGES        2007-12-21 15:13:14 UTC (rev 4784)
+++ trunk/matplotlib/API_CHANGES        2007-12-21 16:22:42 UTC (rev 4785)
@@ -1,3 +1,6 @@
+    For csv2rec, checkrows=0 is the new default indicating all rows
+    will be checked for type inference
+
     A warning is issued when an image is drawn on log-scaled
     axes, since it will not log-scale the image data.
 

Modified: trunk/matplotlib/CODING_GUIDE
===================================================================
--- trunk/matplotlib/CODING_GUIDE       2007-12-21 15:13:14 UTC (rev 4784)
+++ trunk/matplotlib/CODING_GUIDE       2007-12-21 16:22:42 UTC (rev 4785)
@@ -12,6 +12,9 @@
 # checking out the main src
 svn co 
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/matplotlib 
matplotlib --username=youruser --password=yourpass
 
+# branch checkouts, eg the transforms branch 
+svn co 
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/transforms 
transbranch
+
 == Committing changes ==
 
 When committing changes to matplotlib, there are a few things to bear
@@ -27,12 +30,6 @@
     support 2.3, so avoid 2.4 only features like decorators until we
     remove 2.3 support
 
-  * Are your changes Numeric, numarray and numpy compatible?  Try
-    running simple_plot.py or image_demo.py with --Numeric, --numarray
-    and --numpy (Note, someone should add examples to
-    backend_driver.py which explicitly require numpy, numarray and
-    Numeric so we can automatically catch these)
-
   * Can you pass examples/backend_driver.py?  This is our poor man's
     unit test.
 
@@ -49,9 +46,8 @@
 For numpy, use:
 
     import numpy as npy
-    ...
     a = npy.array([1,2,3])
-    ...
+    
 
 For masked arrays, use:
     import matplotlib.numerix.npyma as ma
@@ -64,16 +60,20 @@
 For matplotlib main module, use:
 
     import matplotlib as mpl
-    ...
     mpl.rcParams['xtick.major.pad'] = 6
 
-For matplotlib modules, use:
+For matplotlib modules (or any other modules), use:
 
-    import matplotlib.cbook as cbook as mpl_cbook
-    ...
-    if mpl_cbook.iterable(z):
-        ...
+    import matplotlib.cbook as cbook 
+    
+    if cbook.iterable(z):
+        pass
 
+    We prefer this over the equivalent 'from matplotlib import cbook'
+    because the latter is ambiguous whether cbook is a module or a
+    function to the new developer.  The former makes it explcit that
+    you are importing a module or package.
+
 == Naming, spacing, and formatting conventions ==
 
 In general, we want to hew as closely as possible to the standard
@@ -114,15 +114,6 @@
 python, C and C++
 
 
-When importing modules from the matplotlib namespace
-
-  import matplotlib.cbook as cbook   # DO
-  from matplotlib import cbook       #DONT
-
-because the latter is ambiguous whether cbook is a module or a
-function to the new developer.  The former makes it explcit that you
-are importing a module or package.
-
 ; and similarly for c++-mode-hook and c-mode-hook
 (add-hook 'python-mode-hook
           (lambda ()

Modified: trunk/matplotlib/examples/units/ellipse_with_units.py
===================================================================
--- trunk/matplotlib/examples/units/ellipse_with_units.py       2007-12-21 
15:13:14 UTC (rev 4784)
+++ trunk/matplotlib/examples/units/ellipse_with_units.py       2007-12-21 
16:22:42 UTC (rev 4785)
@@ -1,5 +1,5 @@
 """
-Compare the ellipse generated with arcs versus a polygonal approximation 
+Compare the ellipse generated with arcs versus a polygonal approximation
 """
 from basic_units import cm
 import numpy as npy
@@ -46,4 +46,24 @@
 #fig.savefig('ellipse_compare.png')
 fig.savefig('ellipse_compare')
 
+fig = figure()
+ax = fig.add_subplot(211, aspect='auto')
+ax.fill(x, y, alpha=0.2, facecolor='yellow', edgecolor='yellow', linewidth=1, 
zorder=1)
+
+e1 = patches.Arc((xcenter, ycenter), width, height,
+             angle=angle, linewidth=2, fill=False, zorder=2)
+
+ax.add_patch(e1)
+
+ax = fig.add_subplot(212, aspect='equal')
+ax.fill(x, y, alpha=0.2, facecolor='green', edgecolor='green', zorder=1)
+e2 = patches.Arc((xcenter, ycenter), width, height,
+             angle=angle, linewidth=2, fill=False, zorder=2)
+
+
+ax.add_patch(e2)
+
+#fig.savefig('arc_compare.png')
+fig.savefig('arc_compare')
+
 show()

Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py     2007-12-21 15:13:14 UTC (rev 
4784)
+++ trunk/matplotlib/lib/matplotlib/mlab.py     2007-12-21 16:22:42 UTC (rev 
4785)
@@ -2045,7 +2045,7 @@
     return newrec.view(npy.recarray)
 
 
-def csv2rec(fname, comments='#', skiprows=0, checkrows=5, delimiter=',',
+def csv2rec(fname, comments='#', skiprows=0, checkrows=0, delimiter=',',
             converterd=None, names=None, missing=None):
     """
     Load data from comma/space/tab delimited file in fname into a
@@ -2075,7 +2075,7 @@
     names, if not None, is a list of header names.  In this case, no
     header will be read from the file
 
-    if no rows are found, None is returned See examples/loadrec.py
+    if no rows are found, None is returned -- see examples/loadrec.py
     """
 
     if converterd is None:

Modified: trunk/matplotlib/lib/matplotlib/patches.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/patches.py  2007-12-21 15:13:14 UTC (rev 
4784)
+++ trunk/matplotlib/lib/matplotlib/patches.py  2007-12-21 16:22:42 UTC (rev 
4785)
@@ -977,10 +977,16 @@
     """
     An elliptical arc.  Because it performs various optimizations, it
     can not be filled.
+
+    The arc must be used in an Axes instance it cannot be added
+    directly to a Figure) because it is optimized to only render the
+    segments that are inside the axes bounding box with high
+    resolution.
     """
     def __str__(self):
-        return 
"Arc(%d,%d;%dx%d)"%(self.center[0],self.center[1],self.width,self.height)
 
+        return 
"Arc(%s,%s;%sx%s)"%(self.center[0],self.center[1],self.width,self.height)
+
     def __init__(self, xy, width, height, angle=0.0, theta1=0.0, theta2=360.0, 
**kwargs):
         """
         xy - center of ellipse
@@ -1053,6 +1059,10 @@
         """
         # Do the usual GC handling stuff
         if not self.get_visible(): return
+
+        if not hasattr(self, 'axes'):
+            raise RuntimeError('Arcs can only be used in Axes instances')
+
         gc = renderer.new_gc()
         gc.set_foreground(self._edgecolor)
         gc.set_linewidth(self._linewidth)
@@ -1212,10 +1222,17 @@
 
         # Set up the master transform from unit circle, all the way to
         # display space.
+
+        centerx, centery = self.center
+        centerx = self.convert_xunits(centerx)
+        centery = self.convert_yunits(centery)
+        width = self.convert_xunits(self.width)
+        height = self.convert_yunits(self.height)
+
         trans = self.get_transform()
         scale = npy.array(
-            [[self.width * 0.5, 0.0, 0.0],
-             [0.0, self.height * 0.5, 0.0],
+            [[width * 0.5, 0.0, 0.0],
+             [0.0, height * 0.5, 0.0],
              [0.0, 0.0, 1.0]], npy.float_)
         theta = (self.angle / 180.0) * npy.pi
         rotate = npy.array(
@@ -1223,8 +1240,8 @@
              [npy.sin(theta), npy.cos(theta), 0.0],
              [0.0, 0.0, 1.0]], npy.float_)
         translate = npy.array(
-            [[1.0, 0.0, self.center[0]],
-             [0.0, 1.0, self.center[1]],
+            [[1.0, 0.0, centerx],
+             [0.0, 1.0, centery],
              [0.0, 0.0, 1.0]], npy.float_)
         sx, b, c, sy, tx, ty = trans.as_vec6_val()
         dataTrans = npy.array(
@@ -1240,7 +1257,7 @@
         # that as a threshold to use the fast (whole ellipse)
         # technique or accurate (partial arcs) technique.
         size = affine_transform(
-            npy.array([[self.width, self.height]], npy.float_),
+            npy.array([[width, height]], npy.float_),
             mainTrans)
         width = size[0,0]
         height = size[0,1]

Modified: trunk/matplotlib/unit/ellipse_large.py
===================================================================
--- trunk/matplotlib/unit/ellipse_large.py      2007-12-21 15:13:14 UTC (rev 
4784)
+++ trunk/matplotlib/unit/ellipse_large.py      2007-12-21 16:22:42 UTC (rev 
4785)
@@ -6,7 +6,7 @@
 
 import math
 from pylab import *
-from matplotlib.patches import Ellipse
+from matplotlib.patches import Ellipse, Arc
 
 # given a point x, y
 x = 2692.440
@@ -47,39 +47,75 @@
    ellipseLine = ax.plot( xs, ys, **kwargs )
 
 
+
+
 ##################################################
 # make the axes
-ax = subplot( 211, aspect='equal' )
-ax.set_aspect( 'equal', 'datalim' )
+ax1 = subplot( 311, aspect='equal' )
+ax1.set_aspect( 'equal', 'datalim' )
 
 # make the lower-bound ellipse
 diam = (r - delta) * 2.0
 lower_ellipse = Ellipse( (0.0, 0.0), diam, diam, 0.0, fill=False, 
edgecolor="darkgreen" )
-ax.add_patch( lower_ellipse )
+ax1.add_patch( lower_ellipse )
 
 # make the target ellipse
 diam = r * 2.0
 target_ellipse = Ellipse( (0.0, 0.0), diam, diam, 0.0, fill=False, 
edgecolor="darkred" )
-ax.add_patch( target_ellipse )
+ax1.add_patch( target_ellipse )
 
 # make the upper-bound ellipse
 diam = (r + delta) * 2.0
 upper_ellipse = Ellipse( (0.0, 0.0), diam, diam, 0.0, fill=False, 
edgecolor="darkblue" )
-ax.add_patch( upper_ellipse )
+ax1.add_patch( upper_ellipse )
 
 # make the target
 diam = delta * 2.0
 target = Ellipse( (x, y), diam, diam, 0.0, fill=False, edgecolor="#DD1208" )
+ax1.add_patch( target )
+
+# give it a big marker
+ax1.plot( [x], [y], marker='x', linestyle='None', mfc='red', mec='red', 
markersize=10 )
+
+##################################################
+# make the axes
+ax = subplot( 312, aspect='equal' , sharex=ax1, sharey=ax1)
+ax.set_aspect( 'equal', 'datalim' )
+
+# make the lower-bound arc
+diam = (r - delta) * 2.0
+lower_arc = Arc( (0.0, 0.0), diam, diam, 0.0, fill=False, 
edgecolor="darkgreen" )
+ax.add_patch( lower_arc )
+
+# make the target arc
+diam = r * 2.0
+target_arc = Arc( (0.0, 0.0), diam, diam, 0.0, fill=False, edgecolor="darkred" 
)
+ax.add_patch( target_arc )
+
+# make the upper-bound arc
+diam = (r + delta) * 2.0
+upper_arc = Arc( (0.0, 0.0), diam, diam, 0.0, fill=False, edgecolor="darkblue" 
)
+ax.add_patch( upper_arc )
+
+# make the target
+diam = delta * 2.0
+target = Arc( (x, y), diam, diam, 0.0, fill=False, edgecolor="#DD1208" )
 ax.add_patch( target )
 
 # give it a big marker
 ax.plot( [x], [y], marker='x', linestyle='None', mfc='red', mec='red', 
markersize=10 )
 
+
+
+
+
 ##################################################
 # now lets do the same thing again using a custom ellipse function
 
+
+
 # make the axes
-ax = subplot( 212, aspect='equal', sharex=ax, sharey=ax )
+ax = subplot( 313, aspect='equal', sharex=ax1, sharey=ax1 )
 ax.set_aspect( 'equal', 'datalim' )
 
 # make the lower-bound ellipse
@@ -97,11 +133,17 @@
 # give it a big marker
 ax.plot( [x], [y], marker='x', linestyle='None', mfc='red', mec='red', 
markersize=10 )
 
+
+# give it a big marker
+ax.plot( [x], [y], marker='x', linestyle='None', mfc='red', mec='red', 
markersize=10 )
+
 ##################################################
 # lets zoom in to see the area of interest
 
-ax.set_xlim(2650, 2735)
-ax.set_ylim(6705, 6735)
+ax1.set_xlim(2650, 2735)
+ax1.set_ylim(6705, 6735)
+
+savefig("ellipse")
 show()
 
-savefig("ellipse")
+


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: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to