|
From: <jd...@us...> - 2009-08-30 16:22:47
|
Revision: 7600
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7600&view=rev
Author: jdh2358
Date: 2009-08-30 16:22:38 +0000 (Sun, 30 Aug 2009)
Log Message:
-----------
some unit cleanup; fix sf bug 2846058
Modified Paths:
--------------
branches/v0_99_maint/examples/units/annotate_with_units.py
branches/v0_99_maint/examples/units/bar_demo2.py
branches/v0_99_maint/examples/units/radian_demo.py
branches/v0_99_maint/lib/matplotlib/axes.py
branches/v0_99_maint/lib/matplotlib/collections.py
Modified: branches/v0_99_maint/examples/units/annotate_with_units.py
===================================================================
--- branches/v0_99_maint/examples/units/annotate_with_units.py 2009-08-30 15:43:39 UTC (rev 7599)
+++ branches/v0_99_maint/examples/units/annotate_with_units.py 2009-08-30 16:22:38 UTC (rev 7600)
@@ -1,8 +1,7 @@
-
-import pylab
+import matplotlib.pyplot as plt
from basic_units import cm
-fig = pylab.figure()
+fig = plt.figure()
ax = fig.add_subplot(111)
@@ -23,5 +22,5 @@
ax.set_xlim(0*cm, 4*cm)
ax.set_ylim(0*cm, 4*cm)
-pylab.show()
+plt.show()
Modified: branches/v0_99_maint/examples/units/bar_demo2.py
===================================================================
--- branches/v0_99_maint/examples/units/bar_demo2.py 2009-08-30 15:43:39 UTC (rev 7599)
+++ branches/v0_99_maint/examples/units/bar_demo2.py 2009-08-30 16:22:38 UTC (rev 7600)
@@ -25,11 +25,11 @@
ax3 = fig.add_subplot(2,2,3)
ax3.bar(cms, cms, bottom=bottom, width=width, xunits=inch, yunits=cm)
-ax3.set_xlim(3, 6) # scalars are interpreted in current units
+ax3.set_xlim(2, 6) # scalars are interpreted in current units
ax4 = fig.add_subplot(2,2,4)
ax4.bar(cms, cms, bottom=bottom, width=width, xunits=inch, yunits=inch)
#fig.savefig('simple_conversion_plot.png')
-ax4.set_xlim(3*cm, 6*cm) # cm are converted to inches
+ax4.set_xlim(2*cm, 6*cm) # cm are converted to inches
show()
Modified: branches/v0_99_maint/examples/units/radian_demo.py
===================================================================
--- branches/v0_99_maint/examples/units/radian_demo.py 2009-08-30 15:43:39 UTC (rev 7599)
+++ branches/v0_99_maint/examples/units/radian_demo.py 2009-08-30 16:22:38 UTC (rev 7600)
@@ -7,15 +7,15 @@
from basic_units import radians, degrees, cos
from matplotlib.pyplot import figure, show
-x = np.arange(0, 15, 0.01) * radians
+x = [val*radians for val in np.arange(0, 15, 0.01)]
fig = figure()
fig.subplots_adjust(hspace=0.3)
ax = fig.add_subplot(211)
-ax.plot(x, cos(x), xunits=radians)
+line1, = ax.plot(x, cos(x), xunits=radians)
ax = fig.add_subplot(212)
-ax.plot(x, cos(x), xunits=degrees)
+line2, = ax.plot(x, cos(x), xunits=degrees)
show()
Modified: branches/v0_99_maint/lib/matplotlib/axes.py
===================================================================
--- branches/v0_99_maint/lib/matplotlib/axes.py 2009-08-30 15:43:39 UTC (rev 7599)
+++ branches/v0_99_maint/lib/matplotlib/axes.py 2009-08-30 16:22:38 UTC (rev 7600)
@@ -203,11 +203,25 @@
if self.axes.xaxis is not None and self.axes.yaxis is not None:
bx = self.axes.xaxis.update_units(x)
by = self.axes.yaxis.update_units(y)
- if bx:
- x = self.axes.convert_xunits(x)
- if by:
- y = self.axes.convert_yunits(y)
+ if self.command!='plot':
+ # the Line2D class can handle unitized data, with
+ # support for post hoc unit changes etc. Other mpl
+ # artists, eg Polygon which _process_plot_var_args
+ # also serves on calls to fill, cannot. So this is a
+ # hack to say: if you are not "plot", which is
+ # creating Line2D, then convert the data now to
+ # floats. If you are plot, pass the raw data through
+ # to Line2D which will handle the conversion. So
+ # polygons will not support post hoc conversions of
+ # the unit type since they are not storing the orig
+ # data. Hopefully we can rationalize this at a later
+ # date - JDH
+ if bx:
+ x = self.axes.convert_xunits(x)
+ if by:
+ y = self.axes.convert_yunits(y)
+
x = np.atleast_1d(x) #like asanyarray, but converts scalar to array
y = np.atleast_1d(y)
if x.shape[0] != y.shape[0]:
@@ -4255,10 +4269,14 @@
if self.xaxis is not None:
left = self.convert_xunits( left )
width = self.convert_xunits( width )
+ if xerr is not None:
+ xerr = self.convert_xunits( xerr )
if self.yaxis is not None:
bottom = self.convert_yunits( bottom )
height = self.convert_yunits( height )
+ if yerr is not None:
+ yerr = self.convert_yunits( yerr )
if align == 'edge':
pass
Modified: branches/v0_99_maint/lib/matplotlib/collections.py
===================================================================
--- branches/v0_99_maint/lib/matplotlib/collections.py 2009-08-30 15:43:39 UTC (rev 7599)
+++ branches/v0_99_maint/lib/matplotlib/collections.py 2009-08-30 16:22:38 UTC (rev 7600)
@@ -931,7 +931,9 @@
def set_segments(self, segments):
if segments is None: return
_segments = []
+
for seg in segments:
+
if not np.ma.isMaskedArray(seg):
seg = np.asarray(seg, np.float_)
_segments.append(seg)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|