Revision: 8624
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8624&view=rev
Author:   jrevans
Date:     2010-08-05 17:04:14 +0000 (Thu, 05 Aug 2010)

Log Message:
-----------
Added keyword arguments 'thetaunits' and 'runits' for polar plots.
Fixed PolarAxes so that when it set default Formatters, it marked them as such.
Fixed semilogx and semilogy to no longer blindly reset the ticker information 
on the non-log axis.
Axes.arrow can now accept unitized data.

Modified Paths:
--------------
    trunk/matplotlib/CHANGELOG
    trunk/matplotlib/lib/matplotlib/axes.py
    trunk/matplotlib/lib/matplotlib/projections/polar.py
    trunk/matplotlib/lib/matplotlib/testing/jpl_units/UnitDblConverter.py
    trunk/matplotlib/lib/matplotlib/tests/test_axes.py

Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG  2010-08-04 12:36:13 UTC (rev 8623)
+++ trunk/matplotlib/CHANGELOG  2010-08-05 17:04:14 UTC (rev 8624)
@@ -1,3 +1,10 @@
+2010-08-05 Added keyword arguments 'thetaunits' and 'runits' for polar
+           plots.  Fixed PolarAxes so that when it set default
+           Formatters, it marked them as such.  Fixed semilogx and
+           semilogy to no longer blindly reset the ticker information
+           on the non-log axis.  Axes.arrow can now accept unitized
+           data. - JRE
+
 2010-08-03 Add support for MPLSETUPCFG variable for custom setup.cfg
            filename.  Used by sage buildbot to build an mpl w/ no gui
            support - JDH

Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py     2010-08-04 12:36:13 UTC (rev 
8623)
+++ trunk/matplotlib/lib/matplotlib/axes.py     2010-08-05 17:04:14 UTC (rev 
8624)
@@ -178,7 +178,11 @@
 
         if self.axes.xaxis is not None and self.axes.yaxis is not None:
             xunits = kwargs.pop( 'xunits', self.axes.xaxis.units)
+            if self.axes.name == 'polar':
+                xunits = kwargs.pop( 'thetaunits', xunits )
             yunits = kwargs.pop( 'yunits', self.axes.yaxis.units)
+            if self.axes.name == 'polar':
+                yunits = kwargs.pop( 'runits', yunits )
             if xunits!=self.axes.xaxis.units:
                 self.axes.xaxis.set_units(xunits)
             if yunits!=self.axes.yaxis.units:
@@ -1554,6 +1558,8 @@
         # process kwargs 2nd since these will override default units
         if kwargs is not None:
             xunits = kwargs.pop( 'xunits', self.xaxis.units)
+            if self.name == 'polar':
+                xunits = kwargs.pop( 'thetaunits', xunits )
             if xunits!=self.xaxis.units:
                 #print '\tkw setting xunits', xunits
                 self.xaxis.set_units(xunits)
@@ -1563,6 +1569,8 @@
                     self.xaxis.update_units(xdata)
 
             yunits = kwargs.pop('yunits', self.yaxis.units)
+            if self.name == 'polar':
+                yunits = kwargs.pop( 'runits', yunits )
             if yunits!=self.yaxis.units:
                 #print '\tkw setting yunits', yunits
                 self.yaxis.set_units(yunits)
@@ -3953,7 +3961,6 @@
              }
 
         self.set_xscale('log', **d)
-        self.set_yscale('linear')
         b =  self._hold
         self._hold = True # we've already processed the hold
         l = self.plot(*args, **kwargs)
@@ -4004,7 +4011,6 @@
              'nonposy': kwargs.pop('nonposy', 'mask'),
              }
         self.set_yscale('log', **d)
-        self.set_xscale('linear')
         b =  self._hold
         self._hold = True # we've already processed the hold
         l = self.plot(*args, **kwargs)
@@ -6286,6 +6292,13 @@
 
         .. plot:: mpl_examples/pylab_examples/arrow_demo.py
         """
+        # Strip away units for the underlying patch since units
+        # do not make sense to most patch-like code
+        x = self.convert_xunits(x)
+        y = self.convert_yunits(y)
+        dx = self.convert_xunits(dx)
+        dy = self.convert_yunits(dy)
+
         a = mpatches.FancyArrow(x, y, dx, dy, **kwargs)
         self.add_artist(a)
         return a

Modified: trunk/matplotlib/lib/matplotlib/projections/polar.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/projections/polar.py        2010-08-04 
12:36:13 UTC (rev 8623)
+++ trunk/matplotlib/lib/matplotlib/projections/polar.py        2010-08-05 
17:04:14 UTC (rev 8624)
@@ -220,6 +220,7 @@
         self.title.set_y(1.05)
 
         self.xaxis.set_major_formatter(self.ThetaFormatter())
+        self.xaxis.isDefault_majfmt = True
         angles = np.arange(0.0, 360.0, 45.0)
         self.set_thetagrids(angles)
         
self.yaxis.set_major_locator(self.RadialLocator(self.yaxis.get_major_locator()))

Modified: trunk/matplotlib/lib/matplotlib/testing/jpl_units/UnitDblConverter.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/testing/jpl_units/UnitDblConverter.py       
2010-08-04 12:36:13 UTC (rev 8623)
+++ trunk/matplotlib/lib/matplotlib/testing/jpl_units/UnitDblConverter.py       
2010-08-05 17:04:14 UTC (rev 8624)
@@ -79,11 +79,7 @@
       else:
          label = None
 
-      if ( label == "rad" ):
-         # If the axis units are in radians, then use a special function for
-         # applying format control.
-         majfmt = ticker.FuncFormatter( rad_fn )
-      elif ( label == "deg" ) and isinstance( axis.axes, polar.PolarAxes ):
+      if ( label == "deg" ) and isinstance( axis.axes, polar.PolarAxes ):
          # If we want degrees for a polar plot, use the PolarPlotFormatter
          majfmt = polar.PolarAxes.ThetaFormatter()
       else:

Modified: trunk/matplotlib/lib/matplotlib/tests/test_axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_axes.py  2010-08-04 12:36:13 UTC 
(rev 8623)
+++ trunk/matplotlib/lib/matplotlib/tests/test_axes.py  2010-08-05 17:04:14 UTC 
(rev 8624)
@@ -279,10 +279,12 @@
 @image_comparison(baseline_images=['polar_units'])
 def test_polar_units():
     import matplotlib.testing.jpl_units as units
+    from nose.tools import assert_true
     units.register()
 
     pi = np.pi
     deg = units.UnitDbl( 1.0, "deg" )
+    km = units.UnitDbl( 1.0, "km" )
 
     x1 = [ pi/6.0, pi/4.0, pi/3.0, pi/2.0 ]
     x2 = [ 30.0*deg, 45.0*deg, 60.0*deg, 90.0*deg ]
@@ -299,6 +301,12 @@
 
     fig.savefig( 'polar_units' )
 
+    # make sure runits and theta units work
+    y1 = [ y*km for y in y1 ]
+    plt.polar( x2, y1, color = "blue", thetaunits="rad", runits="km" )
+    assert_true( isinstance(plt.gca().get_xaxis().get_major_formatter(), 
units.UnitDblFormatter) )
+
+
 @image_comparison(baseline_images=['polar_rmin'])
 def test_polar_rmin():
     r = np.arange(0, 3.0, 0.01)


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

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to