[R] plotting large time series
Enrico Schumann
enricoschumann at yahoo.de
Fri Oct 28 09:21:19 CEST 2011
A simple way may be not to plot all data points. But it will depend on
your data if that is a good idea.
Regards,
Enrico
## EXAMPLE
require("zoo")
## random data
dates <- seq(from = as.Date("2000-01-01"),
to = as.Date("2011-10-31"), by = "1 day")
x <- cumsum(rnorm(length(dates)))
## plot all
plot(zoo(x, dates), col = "blue")
## plot every 100th point
subs <- seq(1, length(x), by = 10)
lines(zoo(x[subs], dates[subs]), lwd = 2)
Am 28.10.2011 02:46, schrieb jim holtman:
> Try another format (tiff, jpg, etc) to see how they look, what the
> sizes are for different resolutions. If you have a lot of single
> points, PDF files get very large because of the commands used to print
> each point. If you want to keep PDF, then find some way of
> aggregating the data points so that you plot an "average" of several
> of them. Depending on what you are trying to show, I have used the
> hexbin package to plot large numbers of points.
>
> Why do you need PDFs? Will something else do?
>
> On Thu, Oct 27, 2011 at 11:39 AM, Agnes Richard<agnes.richard at fhnw.ch> wrote:
>> hello,
>>
>> I got a problem with plotting large time series, since I want to store the
>> results in a .PDF file (I want to store several pages of plots). The PDF
>> files get too large to be handled (> 10MB, one was even 200MB big).
>>
>> So I wonder, if there would be a possibilty to either
>> - reduce the file size of the PDF
>> - change the way the plot is generated to reduce the plot size?
>>
>> I use:
>> plot(myDate,myFile[,1],type="l",xlab="Date")
>>
>> using
>> myts = as.ts(start=myDate[1],end=myDate[length(myDate)],x=myFile[,1])
>> plot.ts(myts,xlab="Date")
>>
>> produces the same file size.
>>
>> for storing the PDF I use:
>> pdf(file=paste(outpath,"myPDF.pdf",sep=''),paper="a4r").
>>
>> I would be very grateful for an answer!!!!
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> 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.
>>
>
>
>
--
Enrico Schumann
Lucerne, Switzerland
http://nmof.net/
More information about the R-help
mailing list