[SciPy-user] Still having plotting issue with latest svn scikits.timeseries
Wed Dec 10 12:02:41 CST 2008
On Dec 10, 2008, at 12:32 PM, Dharhas Pothina wrote:
> When I read a datafile in and try to plot it, Whether it plots
> correctly or not depends on what symbols I use in the plot.
I'm very, very surprised. Most likely, some dates get messed up and
don't show up where you expect them.
The plotlib routines only deal with where the data should be, not how
it is plotted.
* When you create a tsplot, you need to specify an associated series
with the 'series' keywords. This series will control the behavior of
the axes. OK, let me get a tad deeper here:
Rmmbr that a DateArray is basically nothing but a int ndarray with
some extra candy. The frequency parameter controls how the dates are
converted to integers, and vice-versa. For example, today (12/10/2008)
is associated with 733386 if you use a daily frequency (that's the
corresponding gregorian proleptic day), with 24096 if you use a
monthly frequency, or simply 2008 if you use an annual frequency.
Plotting a series with tsplot just amounts to plot a standard masked
array with a given set of integers as x coordinates (the dates).
If you don't give a series when you create a tsplot, the first series
to be plotted will be associated with the plot. Its frequency will
dictate how dates are converted.
So, if you plot series #1 with a daily frequency and then series #2
with a monthly frequency on the same graph, some conversion should
happen to make sure that the dates of #2 are actually expressed in the
same frame as series #1. Normally, that happens in the background when
you plot series one after the other, using one command for each
series. If you try to plot several series at once using a single
command, the conversion will happen provided that a frequency was
already associated with the plot.
> If I convert the timeseries using the .convert or .asfreq methods
> the plots work without a problem.
Which is a strong hint that the dates get messed up before you plot.
Are you trying to plot several series with different frequencies ?
> Since I can plot after converting using .asfreq this isn't too much
> of a problem but I was wondering if there is a bug or whether a
> warning should be thrown.
A bug is always possible, but I would tend to think it's a misuse of
the function on your side here. Then, of course, the doc could be
> The dataset and commands I used are below.
OK, thx for the dataset, but please, don't copy-paste directly from
ipython. Just send us the commands, without a prompt (the In[...]), in
a script if you prefer. Right now, I don't have time to spend on
removing these extra characters to check what's going on.
> - dharhas
>>>> "Dharhas Pothina" <Dharhas.Pothina@twdb.state.tx.us> 12/5/2008
>>>> 11:26 AM >>>
> I'm attaching a ascii datafile called JDM3_short.txt and the
> commands I typed in ipython to reproduce the problem. The first
> figure works the second has the correct axes but is blank.
> In : import sys
> In : import subprocess
> In : from numpy import *
> In : from pylab import *
> In : import datetime
> In : import scikits.timeseries as ts
> In : import scikits.timeseries.lib.plotlib as tpl
> In : import numpy.ma as ma
> In : fieldfile='JDM3_short.txt'
> In : year, month, day, hour, minute, fdata =
> In : fielddates =
> [datetime.datetime(int(y),int(m),int(d),int(hh),int(mm),0) for
> y,m,d,hh,mm in zip(year,month,day,hour,minute)]
> In : fdates = ts.date_array(fielddates,freq='MIN')
> In : fseries = ts.time_series(fdata, dates=fdates)
> In : #remove -999.9 nodata values fo parameter
> In : fseries[fseries==-999.9] = ma.masked
> In :
> In : fseries = fseries.fill_missing_dates()
> In : fig = tpl.tsfigure()
> In : fsp = fig.add_tsplot(111)
> In : fsp.tsplot(fseries, '.')
> Out: [<matplotlib.lines.Line2D object at 0x23cafd0>]
> In : fig1 = tpl.tsfigure()
> In : fsp1 = fig1.add_tsplot(111)
> In : fsp1.tsplot(fseries, 'b', label='data')
> Out: [<matplotlib.lines.Line2D object at 0x3109650>]
> In : show()
> - dharhas
>>>> "Dharhas Pothina" <Dharhas.Pothina@twdb.state.tx.us> 12/05/08
>>>> 10:42 AM >>>
> Ok I've narrowed it down. It has nothing to do with plotting two
> timeseries. The problem is plotting the any of the original
> timeseries I read from files. Once I convert them to daily means the
> plotting works fine.
> With the original timeseries whether it plots or not seems to depend
> on what plotting symbol I use.
> - dharhas
>>> If I use two commands and certain other symbols like 'b',b--' etc
>>> for the first series, it only plots the second series :
>> ??? can't reproduce this one...
> I've double checked, its happening consistently with multiple
> datasets (The datasets are similar just at different locations). How
> do I track down the problem? Should I send you a datafile and my
> short script?
> SciPy-user mailing list
More information about the SciPy-user