将绘图保存为 tiff,以高分辨率进行发布(在 R 中)
我们要向其发送文章的期刊要求提供以下信息:
为了确保您的图形具有最佳的再现质量,我们希望获得高分辨率文件。所有图形最好采用 TIFF 或 EPS 格式...并且应具有以下分辨率:
图表:800 - 1200 DPI
照片:400 - 800 DPI
颜色(仅限 CMYK):300 - 400 DPI(DPI = 每英寸点数)
由于我正在发送图表,因此我尝试使用 tiff 保存它。
这是我正在使用的代码:
tiff(filename = "c:\\aaa.tiff",
res = 800, pointsize = 2)
plot(1:100)
dev.off()
但遗憾的是,它产生了一个非常“庞大”的图像 - 如果我在哪里不使用pointsize = 2,我会收到错误消息:
plot.new() 中的错误:图形边距太大
有什么建议吗?
A journal we are sending an article to is asking for the following:
To ensure the best reproduction quality of your figures we would appreciate high resolution files. All figures should preferably be in TIFF or EPS format... and should have the following resolution:
Graph: 800 - 1200 DPI
Photo: 400 - 800 DPI
Color (only CMYK): 300 - 400 DPI (DPI = dots per inch)
Since I am sending a graph, I am trying to save it using tiff.
Here is the code I am using:
tiff(filename = "c:\\aaa.tiff",
res = 800, pointsize = 2)
plot(1:100)
dev.off()
But sadly, it produces a very "bulky" image - and if I where to not use pointsize = 2
, I would get the error message:
Error in plot.new() : figure margins too large
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您应该做的一件事是使用压缩参数。
例如:
LZW 是一种无损压缩格式,所以你不会丢失任何数据,但肯定会减少文件大小。
One thing you should do is use the compression parameter.
For instance:
LZW is a lossless compression format, so you will not lose any data, but you will definitely reduce filesize.
简短回答:
这是一个庞大的文件,因为光栅文件 (TIFF) 的分辨率越高,文件就越大。
另一种选择是 EPS,类似于 PDF 或 PS。只需保存其中任何一个即可。这是一种矢量图像格式,他们说这是可以接受的。它将更加紧凑且质量更高(除非您的图形包含大量点或线。)
长答案:
他们要求的一种格式是 TIFF,一种光栅格式。它将信息保存为代表图像中每个像素的值。如果图像为 100 DPI 和 5 英寸方形,则为 500x500,可保存 250000 像素信息。随着图像分辨率变高且图像尺寸保持不变,所需信息点也会增加。在 200 DPI 时为 1000x1000, 1e6 像素的信息这解释了为什么您的文件如此庞大,
为了在 5 英寸见方处打印出高质量的图像,您需要大约 300-400 DPI(每英寸点数)。这样您就不会看到构成图像的每个单独的小像素。如果分辨率较低,则图像仍然是 5" x 5",但组成图像的每个单独的方块(像素)都很大,您可以看到它们。这就是他们要求做出该决议的原因。否则,图表中的文本和线条会显得块状、锯齿状或模糊。这就是为什么计算机屏幕上的文本(目前只有 100 DPI 左右)的质量不如打印在纸上(通常至少 300 dpi)的质量。
他们要求的另一种格式是 EPS。这是封装后记。由于它是单页文件 PS 或 postscript,因此是等效的。并且,PDF也类似。这些都是矢量格式,本质上是相同的矢量格式(它们也可以包含光栅格式图像,但我们忽略这一点)。
矢量格式文件保存有关如何绘制图像的信息,但不保存有关每个像素的信息。如果 x 轴长 3 英寸,距离图像底部 0.5 英寸,则矢量文件知道此描述。文件中描述了图表的每个特征。因此,对于简单的绘图来说,在给定的图像质量下,它比任何光栅表示要紧凑得多。此外,它可以在不损失质量的情况下扩大规模。您只需要求它以 6" x 6" 而不是 5" x 5" 的尺寸绘制图像,它也会缩放用于绘制图像组件的每个指令。因此,即使 PDF 或 EPS 文件更加紧凑,它也会以最高质量打印。
发送 PDF 或 PS 文件,无需担心分辨率。
short answer:
It's a bulky file because the higher the resolution raster file (TIFF) then the larger the file.
The other option, EPS, is like PDF or PS. Just save in any of those. That's a vector image format and one they said was acceptable. It will be more compact and of higher quality (unless your figure contains an enormous number of points or lines.)
long answer:
One format they asked for is TIFF, a raster format. It saves the information as a value representing each pixel in the image. If the image is 100 DPI and 5" square then that's 500x500 and it saves 250000 pixels of information. As the resolution of the image gets higher and the image size stays constant then the points of information needed goes up. At 200 DPI it's 1000x1000 and 1e6 pixels of information. This explains why your file is so bulky.
In order to have a quality printed image at 5" square you would need about 300-400 DPI (dots per inch). That way you won't see each of those individual little pixels that make up the image. If it's at a lower resolution then the image is still 5" x 5" but each individual square block (pixel) that makes up the image is so large you can see them. That's why they asked for that resolution. Otherwise, text and lines in your graphs would appear blocky, jaggy, or blurry. It's why text on your computer screen (only around 100 DPI these days) isn't nearly as high quality as printed on a piece of paper (usually at least 300 dpi).
The other format they asked for was EPS. This is encapsulated postscript. Since it's a single page file PS, or postscript, would be equivalent. And, PDF is also similar. These are all vector formats, essentially the same vector format (they can contain raster format images too but let's ignore that).
A vector format file saves the information about how the image was drawn but not about each pixel. If you have an x-axis 3" long placed 0.5" from the bottom of the image then the vector file knows this description. Each feature of the graph is described in the file. Because of this, for simple drawings it is vastly more compact than any raster representation at a given image quality. Furthermore, it scales in size without losing quality. You simply ask it to draw the image at 6" x 6" instead of 5" x 5" and it scales each of the instructions for drawing the components of the image up as well. Therefore, even though the PDF or EPS file will be more compact, it will print at the highest quality.
Send a PDF or PS file and don't worry about the resolution.
当您提高分辨率 (
res
) 时,绘图的有效大小会减小,因此边距误差会跳出。尝试用更大的宽度
和高度
制作更大的图片(理论上,要制作相同虚拟尺寸的图,应该是new_(width|height) =res/72*old_(宽度|高度)
。尽管如此,正如 romunov 所建议的,使用 ImageMagick 是一个更好的主意;你不会失去质量。
When you increase resolution (
res
), the effective size of a plot decreases, and so the margin error jumps out. Try to make bigger picture with greaterwidth
andheight
(in theory, to make a plot of a same virtual size, it should benew_(width|height)=res/72*old_(width|height)
.Still, as romunov suggested, it is a better idea to use ImageMagick; you won't loose quality.
我建议您使用
R.devices
库中的devEval
。我自己也遇到了这个问题,并解决了这个问题:
对我来说,它就像一个魅力,文件直接保存,没有问题。
I would suggest you to use
devEval
from theR.devices
library.I had this issue myself and solved it thanks to this :
For me it worked like a charm and the file was saved directly without issue.