Not knowing anything about your data I can produce a black rectangle in 11 s
from a 1/40 of your data size.
> x <- 1 : 1e5
> y <- sample (1:20, length (x), replace = TRUE)
> system.time (plot (x, y, type = "l"))
user system elapsed
4.080 0.020 4.097
> p <- ggplot(data.frame (x = x, y = y),aes(x=x,y=y)) + geom_line()
> system.time (print (p))
user system elapsed
10.59 0.03 10.65
However, plotting 4e6 values along x means some thousand values compressed into
one screen pixel. So: if you don't have a kind of structure on that scale,
you're not going to see anything with the line approach.
=> in that case: you need to compute some summary statistic (tiles, running
average, ...). Without knowing what your data means, no one can tell what does
make sense and what doesn't.
If the data is (somewhat) sorted, you can use rle()
y <- sort (y)
> system.time ({
+ yr <- rle (y)
+ data <- data.frame (x = c (0, cumsum (yr$lengths)),
+ y = c (1, yr$values))
+ p <- ggplot(data,aes(x=x,y=y)) + geom_step(direction = "vh")
+ print (p)
+ })
user system elapsed
0.960 0.000 0.973
HTH,
Claudia
--
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Universit� degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste
phone: +39 0 40 5 58-37 68
email: cbel...@units.it
baptiste
N <- 1e5
d <- data.frame(x=seq(1,N), y=rnorm(N), id=rep(seq(1,N/2),each=2))
## version for segments
xx <- rep(d$x, each=2)[-c(1, 2*N)]
yy <- rep(d$y, each=2)[-c(1, 2*N)]
start <- seq(1, by=2, length(xx)) # starting points
end <- seq(2, by=2, length(yy)) # end points
d2 <- data.frame(x0=xx[start], x1=xx[end],
y0=yy[start], y1=yy[end],
id=rep(seq(1,N-1),each=2))
## drawing
p1 <- qplot(x,y,data=d,geom="line")
p2 <- p1 + aes(group=id)
g1 <- with(d, polylineGrob(x/N, y/2))
g2 <- with(d, polylineGrob(x/N, y/2, id=id))
g3 <- with(d2, segmentsGrob(x0/N,y0/2,x1/N,y1/2, gp=gpar(col=id)))
png()
system.time(print(p1))
system.time(print(p2))
grid.newpage()
system.time(grid.draw(g1))
grid.newpage()
system.time(grid.draw(g2))
grid.newpage()
system.time(grid.draw(g3))
dev.off()
## user system elapsed
## 9.657 1.118 11.022
## > user system elapsed
## 117.253 23.795 144.114
## > > user system elapsed
## 0.729 0.009 0.753
## > > user system elapsed
## 0.849 0.019 0.885
## > > user system elapsed
## 3.094 0.018 3.134
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>