I have a scatter plot with many data points in it. Once I try to zoom in or save it in a pdf format, it takes a long time to open and the pdf is too large. How can I reduce the file size or make the plot lighter by keeping the same visuality of the plot. Here is an example:
library(ggplot2)
df <- data.frame(x = rnorm(50000),y=rnorm(50000))
ggplot(df,aes(x=x,y=y)) + geom_point()
Not sure what you mean with visibility. But what about the following?
library(ggplot2)
df <- data.frame(x = rnorm(50000),y=rnorm(50000))
ggplot(df,aes(x=x,y=y)) + geom_point()
ggsave('C:/yourpath/test.png', dpi = 600)
This should result in a .png file of roughly 85 kb.
If you want to increase the quality of the picture, you can increase dpi
into 1200
or higher.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With