Hi Thomas, The issue comes from Pylab not knowing how to deal with instances of Sage's RealNumber class. When you do "4.0" from the command line, it gets changed into "RealNumber('4.0')". You can see this with the following commands:
sage: preparse('4.0') "RealNumber('4.0')" In order to get Pylab to work as expected there are two easy solutions: 1) Run "RealNumber = float" to get Sage to return Python floats instead of RealNumbers. See below: sage: type(4.0) <type 'sage.rings.real_mpfr.RealNumber'> sage: RealNumber = float sage: type(4.0) <type 'float'> 2) Turn off the preparser when using Pylab: sage: preparser(False) sage: type(4.0) <type 'float'> Hope this helps. --Mike On Sun, Jun 1, 2008 at 12:57 PM, tkeller <[EMAIL PROTECTED]> wrote: > > Hi folks, > Sorry to bombard the mailing list with questions, I'm starting to use > sage for more and more things lately. I'm trying to get a figure > together for a paper and thought I'd try using the bar() command in > pylab. However, the following code (modeled after an example in > matplotlib) gives an error. I thought maybe a problem with number > coercion was causing the issue, but explicitly casting the numbers as > floats has no effect. I should mention that I'm completely new to > matplotlib, so it could be that I'm just not supplying arguments > correctly. > > import pylab as p > p.close() > pos=p.arange(4.0,dtype=float) > width=0.35 > dat=p.array([-2.0,10.4,30.0,29.9],dtype=float) > p.bar(pos,dat,width,color='b') > p.savefig('sage.png') > > This returns : > File "/home/thomas/.sage/sage_notebook/worksheets/admin/10/code/ > 2.py", line 11, in <module> > p.bar(pos,dat,width,color='b') > File "/home/thomas/sage/local/lib/python2.5/site-packages/matplotlib/ > pyplot.py", line 1402, in bar > ret = gca().bar(*args, **kwargs) > File "/home/thomas/sage/local/lib/python2.5/site-packages/matplotlib/ > axes.py", line 3293, in bar > self.add_patch(r) > File "/home/thomas/sage/local/lib/python2.5/site-packages/matplotlib/ > axes.py", line 1145, in add_patch > self._update_patch_limits(p) > File "/home/thomas/sage/local/lib/python2.5/site-packages/matplotlib/ > axes.py", line 1153, in _update_patch_limits > self.update_datalim(xys) > File "/home/thomas/sage/local/lib/python2.5/site-packages/matplotlib/ > axes.py", line 1180, in update_datalim > self.dataLim.update_numerix_xy(xys, -1) > TypeError: Bbox::update_numerix_xy expected numerix array > > If anyone has some insight into this, I'd greatly appreciate it. > Thomas > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---