2

I'm making a plot in R using ggplot2 library. The thing is that a plot like the one produced by the code shown below is taking too much time to render, I'm using a PC with 16 GB RAM and an octacore i7 running windows 10 (R version = 3.6.2, 64 bit), as you can see in the benchmark shown below the process takes about 45 seconds to render, I ran the same code on rstudio.cloud (free version) and it took just 1 second, also I tried at another PC (8 GB RAM, i5, Windows 8.1, the graphics card is the same as mine) and it took 26 seconds.

The thing is the surprising slowness of the process on a reasonably high-end PC, in fact, it renders faster in a slower PC.

Is there a way to solve this issue, or at least, to know why is this happening?

Thanks in advance!

library(ggplot2)
df <- data.frame(x=rnorm(30100, 6, 2), y=runif(30100, -3, 5))

df$color <- df$x*df$y

p1 <- ggplot(df, aes(x, y, color=color))+
  geom_point(shape=45, alpha=0.3)+
  theme_void()+
  theme(legend.position = "NA")+
  scale_colour_gradient2(mid="black",
                         low= "red", high  = "green")

benchplot(p1)
#>        step user.self sys.self elapsed
#> 1 construct      0.00     0.00    0.00
#> 2     build      0.28     0.02    0.29
#> 3    render      0.05     0.00    0.06
#> 4      draw      0.55    41.92   43.74
#> 5     TOTAL      0.88    41.94   44.09

Created on 2020-02-17 by the reprex package (v0.3.0)

OranWuTan
  • 21
  • 1
  • 5

0 Answers0