I came up with a partial solution for my problem. I found an example from
Sandro Tosi (http://www.packtpub.com/article/advanced-matplotlib-part2. I
think I may have to buy his book.) using datutil.parser. I'm not sure why a
straight numpy.load doesn't work.

Code was:
 > I tried to import my own data. It looks like 
 >    2005-03-04,0.923115796
 >    2005-03-05,0.915828724
 >    2005-03-06,0.442521474
 >    2005-03-07,0.997096213
 >    2005-03-08,0.867752118
 > And to import, I use recarray
 >   myarray = np.loadtxt(fullfile, dtype=[('date', '|O4'), ('ydata',
 > 'float')], delimiter = ',')
 >   rx = myarray.view(np.recarray)
 > 
 > Data imports fine. But when I go to plot, I get the following error
 >   ValueError: setting an array element with a sequence.
 >   WARNING: Failure executing file: <bogus.py>

If I modify to:

  import datutil

  myarray = np.loadtxt(fullfile, dtype=[('datestring', '|S22'), ('ydata',
'float')], delimiter = ',')
  dates = [dateutil.parser.parse(s) for s in myarray['datestring']]

Now I can plot with
  plt.plot(dates, myarray['ydata']

Bill Eaton






------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to