Plotting a large time series

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Plotting a large time series

Adrian Mcmenamin
I have a time series with many millions of points.

Each point is of the form (time, value) but where the value is 0 there is
no record - ie the data set is sparse.

If I plot this using plot(myData) I get a correct plot going from time 0 to
time 7x10e7.

Given that there are many millions of points (it's not *that* sparse), this
looks very busy.

But if I attempt to plot this as a line - plot(myData, type="l") - the plot
is wrong (it looks like solid semi-sinusoidal curves) and although the
x-axis is drawn from 0 to 7x10e7, the plotting stops at about 3x10e7.

The same thing is seen if I use plot(myData[[1]], myData[[2]], type="l").

If I use plot(myData[[2]], myData[[1]], type="l") I do get a line (albeit
that the orientation seems odd), but again, while the y-axis is drawn
between 0 and 7x10e7, the plotting again seems to stop at 3x10e7 or
thereabouts.

What have I got wrong? How can I get a line (preferably with the standard
orientation)?

Adrian

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Plotting a large time series

Jim Lemon-4
Hi Adrian,
This is probably taking a long time. I first tried with 7x10^6 times
and values and it took several minutes. The following code does what I
expected:

amdat<-data.frame(time=1:700000,value=rnorm(700000,-4))
amdat$value[amdat$value<0]<-0
sum(amdat$value)
[1] 5.07101
plot(amdat$time,amdat$value)
plot(amdat$time,amdat$value,type="l")

Perhaps convert the time series to two ordinary vectors?

Jim


On Sat, Apr 23, 2016 at 9:37 PM, Adrian Mcmenamin <[hidden email]> wrote:

> I have a time series with many millions of points.
>
> Each point is of the form (time, value) but where the value is 0 there is
> no record - ie the data set is sparse.
>
> If I plot this using plot(myData) I get a correct plot going from time 0 to
> time 7x10e7.
>
> Given that there are many millions of points (it's not *that* sparse), this
> looks very busy.
>
> But if I attempt to plot this as a line - plot(myData, type="l") - the plot
> is wrong (it looks like solid semi-sinusoidal curves) and although the
> x-axis is drawn from 0 to 7x10e7, the plotting stops at about 3x10e7.
>
> The same thing is seen if I use plot(myData[[1]], myData[[2]], type="l").
>
> If I use plot(myData[[2]], myData[[1]], type="l") I do get a line (albeit
> that the orientation seems odd), but again, while the y-axis is drawn
> between 0 and 7x10e7, the plotting again seems to stop at 3x10e7 or
> thereabouts.
>
> What have I got wrong? How can I get a line (preferably with the standard
> orientation)?
>
> Adrian
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.