#10366: plotting dates requires a toordinal() call, which is inconvenient
---------------------------+------------------------------------------------
   Reporter:  jason        |       Owner:  jason, was
       Type:  enhancement  |      Status:  new       
   Priority:  major        |   Milestone:  sage-4.6.1
  Component:  graphics     |    Keywords:            
     Author:               |    Upstream:  N/A       
   Reviewer:               |      Merged:            
Work_issues:               |  
---------------------------+------------------------------------------------
 This doesn't work:
 {{{
 sage: version()
 'Sage Version 4.6, Release Date: 2010-10-30'
 sage: from matplotlib.dates import YearLocator, DateFormatter
 sage: import datetime
 sage:
 sage: data=[
 ....: (datetime.date( 1995, 1, 1 ), 30),
 ....: (datetime.date( 1996, 3, 1 ), 50),
 ....: (datetime.date( 1997, 2, 4 ), 40),
 ....: ]
 sage:
 sage:
 sage:
 
list_plot(data,ticks=[YearLocator(),None],tick_formatter=[DateFormatter('%Y-%m-%d'),None])
 ---------------------------------------------------------------------------
 TypeError                                 Traceback (most recent call
 last)

 /Users/grout/<ipython console> in <module>()

 /Users/grout/sage/local/lib/python2.6/site-packages/sage/plot/misc.pyc in
 wrapper(*args, **kwds)
     136                 options['__original_opts'] = kwds
     137             options.update(kwds)
 --> 138             return func(*args, **options)
     139
     140

 /Users/grout/sage/local/lib/python2.6/site-packages/sage/plot/plot.pyc in
 list_plot(data, plotjoined, **kwargs)
    3523         P = line(data, **kwargs)
    3524     else:
 -> 3525         P = point(data, **kwargs)
    3526     return P
    3527

 /Users/grout/sage/local/lib/python2.6/site-packages/sage/plot/point.pyc in
 point(points, **kwds)
     310     except (ValueError, TypeError):
     311         from sage.plot.plot3d.shapes2 import point3d
 --> 312         return point3d(points, **kwds)
     313
     314 @rename_keyword(color='rgbcolor', pointsize='size')

 /Users/grout/sage/local/lib/python2.6/site-
 packages/sage/plot/plot3d/shapes2.pyc in point3d(v, size, **kwds)
    1009         return Point(v, size, **kwds)
    1010     else:
 -> 1011         A = sum([Point(z, size, **kwds) for z in v])
    1012         A._set_extra_kwds(kwds)
    1013         return A

 /Users/grout/sage/local/lib/python2.6/site-
 packages/sage/plot/plot3d/shapes2.pyc in __init__(self, center, size,
 **kwds)
     672         """
     673         PrimitiveObject.__init__(self, **kwds)
 --> 674         self.loc = (float(center[0]), float(center[1]),
 float(center[2]))
     675         self.size = size
     676         self._set_extra_kwds(kwds)

 TypeError: float() argument must be a string or a number

 }}}

 But inserting a toordinal() call for each date does work.  It would be
 really nice if Sage intelligently handled date data and did something like
 this automatically.

 {{{
 sage: list_plot([(i.toordinal(), j) for i,j in
 
data],ticks=[YearLocator(),None],tick_formatter=[DateFormatter('%Y-%m-%d'),None])

 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10366>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to