* 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"
gnuplot does handle file plots nicely -- here is an example of how to
parse files with date entries and plot them in matplotlib. Basically,
the load function takes a dictionary mapping column index to a
converter function which returns a float.
from pylab import figure, show, datestr2num, load
dates, closes = load(
'data/msft.csv', delimiter=',',
converters={0:datestr2num}, skiprows=1, usecols=(0,2),
unpack=True)
fig = figure()
ax = fig.add_subplot(111)
ax.plot_date(dates, closes)
show()
The function datestr2num takes any date string recognized by
dateutils.parse (most of them) and returns a floating point number
days since 0000-00-00 which is how matplotlib represents dates.
> * 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.
We have steps too!
plot(x, y, linestyle='steps')
Hope this helps,
JDH