Re: geom_points data capacity?

37 views
Skip to first unread message

Frans Slothouber

unread,
Sep 14, 2012, 9:20:20 AM9/14/12
to matdodds, ggp...@googlegroups.com
Hoi,

The following

require(ggplot2)
zz <- data.frame( xx <- runif(n=750000 ), yy <- runif(n=750000) )
ggplot(zz,aes(x=xx,y=yy))+geom_point()

takes about a minute to plot on my machine ( dual core, 4Gig )

But with so many point you might want to use a different kind of plot,
or just plot a sample of data.

If you save such a plot as pdf it will take a very long time to render too.


Frans.

On 13 September 2012 22:15, matdodds <matthe...@hotmail.com> wrote:
> Hi ggplotters,
>
> I'm new to R and ggplot. I'm working in RStudio and trying to scatterplot
> some data from a microarray background correction using ggplot.
>
> I entered the code below
>
> p <- ggplot(data.mas, aes(x=raw.log, y=bgcorr.log, colour=cel))
> p <- p + geom_point(shape=".")
> p
>
> but my machine simply freezes, obviously doing a lot of work but producing
> nothing. Eventually I had to kill RStudio. Is the scale of the data an issue
> here? (there's ~750k rows of data)
>
> summary(p)
> data: cel, raw, bg.correct, bg.only,
> bg.method, raw.log, bgcorr.log,
> bgonly.log [743895x8]
> mapping: x = raw.log, y = bgcorr.log, colour = cel
> faceting: facet_null()
> -----------------------------------
> geom_point: na.rm = FALSE, shape = .
> stat_identity:
> position_identity: (width = NULL, height = NULL)
>
> suggestions, pointers as to how I can get these data plotted would be very
> welcome. please could these be clear-for-a-beginner! thanks
>
> M
>
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2

Brian Diggs

unread,
Sep 14, 2012, 12:00:53 PM9/14/12
to ggplot2
On 9/14/2012 6:20 AM, Frans Slothouber wrote:
> Hoi,
>
> The following
>
> require(ggplot2)
> zz <- data.frame( xx <- runif(n=750000 ), yy <- runif(n=750000) )
> ggplot(zz,aes(x=xx,y=yy))+geom_point()
>
> takes about a minute to plot on my machine ( dual core, 4Gig )

I get similar timings:

> system.time(print(ggplot(zz,aes(x=xx,y=yy))+geom_point()))
user system elapsed
18.78 10.31 29.12
> benchplot(ggplot(zz,aes(x=xx,y=yy))+geom_point())
step user.self sys.self elapsed
1 construct 0.05 0.03 0.08
2 build 7.84 0.75 8.62
3 render 4.58 1.00 5.59
4 draw 3.39 8.60 12.02
5 TOTAL 15.86 10.38 26.31

Quad core, 16GB, 64 bit Windows 7, running just Rterm.

You may be having memory issues (though 750,000 * 4 bytes * 2 dimenions
~ 6MB, so I would doubt that), or it may be related to Rstudio (I
believe that Rstudio has its own graphics device, but I may be recalling
that incorrectly).

> But with so many point you might want to use a different kind of plot,
> or just plot a sample of data.
>
> If you save such a plot as pdf it will take a very long time to render too.

Both of these are very good points.

>
> Frans.
>> To post: email ggplot2-/JYPxA39Uh5...@public.gmane.org
>> To unsubscribe: email ggplot2+unsubscribe-/JYPxA39Uh5...@public.gmane.org
>> More options: http://groups.google.com/group/ggplot2
>


--
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health & Science University

Frans Slothouber

unread,
Sep 14, 2012, 12:36:42 PM9/14/12
to Brian Diggs, ggplot2
Forgot to specify; the timings I got were under RStudio.
So I don't think RStudio is the problem.

Brandon Hurr

unread,
Sep 14, 2012, 12:45:24 PM9/14/12
to Frans Slothouber, Brian Diggs, ggplot2
system.time(print(ggplot(zz,aes(x=xx,y=yy))+geom_point()))
   user  system elapsed 
 37.061   2.985  40.004 

MacbookAir 1.7Ghz 4GB

Didn't really seem that long considering how many points it's plotting. Definitely look at summarizing the data and then plotting if possible/appropriate. 

matdodds

unread,
Sep 21, 2012, 6:45:09 AM9/21/12
to ggp...@googlegroups.com
@everyone: many thanks for your suggestions .... I'm trimmed the data size by sampling and hey presto end of issue.
chs
M
Reply all
Reply to author
Forward
0 new messages