如何在R中保存很多点的pdf文件 [英] How to save a pdf in R with a lot of points

查看:374
本文介绍了如何在R中保存很多点的pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我必须保存一个包含很多点的pdf图.那不是问题.问题是当我打开它时.永远绘制所有这些点.我如何保存这种pdf文件,而不必在有人打开它时逐点绘制它.如果图像质量下降一点,我可以.

So I have to save a pdf plot with a lot of points in it. That is not a problem. The problem is that when I open it. It takes forever to plot all those points. How can I save this pdf in such a way that it doesn't have to draw point by point when someone opens it. I'm OK if the quality of the picture goes down a bit.

这是一个样本.我认为这不会使您的计算机崩溃,但是如果您有一台旧计算机,请注意参数长度.顺便说一句,我在实际问题中使用的积分要多得多.

Here's a sample. I don't think this would crash your computer but be careful with the parameter length if you have an old machine. I am using many more points than that in my real problem by the way.

pdf("lots of points.pdf")
x <- seq(0,100, length = 100000)
y <- 0.00001 * x
plot(x, y)
dev.off()

推荐答案

我遇到了类似的问题,并且有一个合理的解决方案.缺点是该解决方案不是通用的,并且不涉及编程(总是很糟糕).

I had a similar problem and there is a sound solution. The drawback is that this solution is not generic and does not involve programming (always bad).

出于草稿目的,png或任何其他图形格式可能就足够了,但出于演示目的,通常不是这种情况.因此,解决方法是将矢量图形用于字体,轴等,并将位图用于数百万个点:

For draft purposes, png or any other graphic format may be sufficient, but for presentation purposes this is often not the case. So the way to go is to combine vector graphics for fonts, axis etc and bitmap for your zillions of points:

1)另存为pdf(巨大且令人讨厌)

1) save as pdf (huge and nasty)

2)加载到Illustrator中或同样(必须具有图层)

2) load into illustrator or likewise ( must have layers )

3)通过将其他东西拖到新层来将点与所有其他东西分开-另存为A

3) separate points from all other stuff by dragging other stuff to new layer - save as A

4)删除其他内容,仅将点导出为位图(png,jpg),另存为B

4) delete other stuff and export points only as bitmap (png, jpg) and save as B

5)将B加载到A中;缩放并移动B到完全重叠;删除矢量点图层,并导出为细长的pdf.

5) load B into A; scale and move B to exact overlap; delete vector points layer, and export as slender pdf.

完成.需要30分钟.

如上所述,这与编程无关,但是根本无法解决这样的事实:作为矢量图形的每个点(甚至是不可见的点,因为被其他人覆盖)都是单个元素,这很痛苦.处理包含数千个元素的pdf. 因此,需要进行后处理.我知道ImageMagick可以做很多事情,但是上述AFAIK不能通过算法完成.

As said this has nothing to do with programming, but there is simply no way around the fact that as vector graphics each and every point (even those that are not visible, since covered by others) are single elements and its a pain handling pdfs with thousands of elements. So there is need for postprocessing. I know ImageMagick can do alot, but AFAIK the above cant be done by an algorithm.

(部分)解决此问题的唯一编程方法是,消除由于其他点覆盖而不会显示的那些点.但是那超出了我.

The only programming way to (partly) solve this is to eliminate those points that will not display because the are covered by others. But thats beyond me.

仅当您确实非常需要极高的可伸缩性时,才采用这种方式,否则,请使用@Ben和@inform并在您需要的任何容器中使用位图(png,pdf,bmp,jpg,tif甚至是eps)

Only go this way if you really and desperately need extreme scalability, otherwise go with @Ben and @inform and use a bitmap --in whatever container you need it (png,pdf,bmp,jpg,tif, even eps).

这篇关于如何在R中保存很多点的pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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