本文介绍了剧情以PDF位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前工作的CGH阵列的结果,涉及几十个千点的几个情节,我想从PDF设备和PNG图像格式的亮度的多页功能中获益。

问题是,PDF存储设备的田块作为矢量图形,所以PDF文件是巨大的,需要几分钟才能打开。我不知道如果R能够绘制嵌入在一个单一的PDF文件作为多个位图,因为我知道能够处理它为PDF格式。

下面是一个简单的例子,PDF文件约2个月,而PNG的是约10高,所以我想一个PDF文件约20高。

  PNG(测试%i.png)
积(RNORM(2E4),RNORM(2E4),PCH =+,CEX = 0.6)
积(RNORM(2E4),RNORM(2E4),PCH =+,CEX = 0.6)
dev.off()PDF(的test.pdf,onefile = TRUE)
积(RNORM(2E4),RNORM(2E4),PCH =+,CEX = 0.6)
积(RNORM(2E4),RNORM(2E4),PCH =+,CEX = 0.6)
dev.off()


解决方案

下面是一个让你接近(50KB)到你想要的文件大小(25KB),而不需要安装LaTeX的和/或学习Sweave的解决方案。 (不,无论是那些处于长期的不良!)

它使用电网功能 grid.cap() grid.raster( )。更多的细节和想法在:

 要求(网格)
#使地块
dev.new()#减少这种设备将产生较小的光栅文件的宽度和高度
    积(RNORM(2E4),RNORM(2E4),PCH =+,CEX = 0.6)
    CAP1< - grid.cap()
    剧情(RNORM(2E4),RNORM(2E4),PCH =+,CEX = 0.6,列=红)
    CAP2< - grid.cap()
dev.off()#把它们写为PDF
PDF(的test.pdf,onefile = TRUE)
     grid.raster(CAP1)
     plot.new()
     grid.raster(CAP2)
dev.off()

生成的 PDF 图像看上去比你的文件,以保留更多的细节 test1.png test2.png ,所以你可以通过修剪下来的分辨率更贴近你的目标。

I am currently working on CGH array results, which involve several plots of dozens of thousands of points, and i would like to benefit from the multiple page feature of the PDF device and the lightness of the PNG image format.

The problem is that the PDF device stores the plots as vectorial drawings, so the PDF files are huge and take several minutes to open. I wonder if R can plot as multiple bitmaps embedded in a single PDF file, as i know the PDF format able to handle it.

Here is a simple example, the PDF file is about 2 Mo while the png ones are about 10 Ko, so I'd like a PDF file of about 20 Ko.

png("test%i.png")
plot(rnorm(2e4), rnorm(2e4), pch="+", cex=0.6)
plot(rnorm(2e4), rnorm(2e4), pch="+", cex=0.6)
dev.off()

pdf("test.pdf", onefile=TRUE)
plot(rnorm(2e4), rnorm(2e4), pch="+", cex=0.6)
plot(rnorm(2e4), rnorm(2e4), pch="+", cex=0.6)
dev.off()
解决方案

Here's a solution that gets you close (50kb) to your desired file size (25kb), without requiring you to install LaTeX and/or learn Sweave. (Not that either of those are undesirable in the long-run!)

It uses the grid functions grid.cap() and grid.raster(). More details and ideas are in a recent R-Journal article by Paul Murrell (warning : PDF):

require(grid)
# Make the plots
dev.new()  # Reducing width and height of this device will produce smaller raster files
    plot(rnorm(2e4), rnorm(2e4), pch="+", cex=0.6)
    cap1 <- grid.cap()
    plot(rnorm(2e4), rnorm(2e4), pch="+", cex=0.6, col="red")
    cap2 <- grid.cap()
dev.off()

# Write them to a pdf
pdf("test.pdf", onefile=TRUE)
     grid.raster(cap1)
     plot.new()
     grid.raster(cap2)
dev.off()

The resulting pdf images appear to retain more detail than your files test1.png and test2.png, so you could get even closer to your goal by trimming down their resolution.

这篇关于剧情以PDF位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 05:30