geom_point包含许多数据点,图的文件大小太大. [英] geom_point with many data points, the file size of the plot is too big.

查看:96
本文介绍了geom_point包含许多数据点,图的文件大小太大.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个散点图,其中包含许多数据点.一旦我尝试放大或将其保存为pdf格式,打开它会花费很长时间,并且pdf太大.如何通过保持图的相同外观来减小文件大小或使图更浅.这是一个示例:

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)

这将导致大约85 kb的.png文件.

This should result in a .png file of roughly 85 kb.

如果要提高图片质量,可以将dpi增加到1200或更高.

If you want to increase the quality of the picture, you can increase dpi into 1200 or higher.

这篇关于geom_point包含许多数据点,图的文件大小太大.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆