You can use python's time module to parse dates, see time.strptime and time.strftime.

Jonathan

Marquardt, Colin wrote:

[Repost, sorry if you get this twice.]

Hi guys,

in my quest for a better gnuplot replacement, I came across matplotlib
yesterday.

I really like it, big thanks to the developers.

It was pretty easy to port over a gnuplot command file.  There are
two things that could have been easier still though:

* My data file consists of a date (in ISO format) and integers. Parsing
  the date was a bit of work. I understand that python's datetime doesn't
  provide any parsing of dates - but maybe matplotlib should have some
  functions for that then?  FWIW, here is how gnuplot does this (adapted
  from http://t16web.lanl.gov/Kawano/gnuplot/datetime-e.html):

     set xdata time
     set timefmt "%Y-%m-%d"
     set format x "%Y-%m"

  In my matplotlib script, I'm now doing:

     mydate = [int(elem) for elem in vals_line[0].split('-')]
datenums.append(date2num(datetime.date(mydate[0], mydate[1], mydate[2])))
     [...]
     plotline = plot_date(datenums, data)

* gnuplot has a plot style "steps"
  (http://t16web.lanl.gov/Kawano/gnuplot/intro/style-e.html) - I
  could only fake that with with extra "dummy" points in matplotlib
  as I understand it. It would be nice if matplotlib could do this
  for me.

Cheers,
  Colin


--
------------------------------------------------------------------------
I'm part of the Team in Training: please support our efforts for the
Leukemia and Lymphoma Society!

http://www.active.com/donate/tntsvmb/tntsvmbJTaylor

GO TEAM !!!

------------------------------------------------------------------------
Jonathan Taylor                           Tel:   650.723.9230
Dept. of Statistics                       Fax:   650.725.8977
Sequoia Hall, 137                         www-stat.stanford.edu/~jtaylo
390 Serra Mall
Stanford, CA 94305



-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to