找回密码
 注册
查看: 7569|回复: 0

R语言:png()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-17 09:59:26 | 显示全部楼层 |阅读模式
png(grDevices)
png()所属R语言包:grDevices

                                        BMP, JPEG, PNG and TIFF graphics devices
                                         JPEG,BMP,PNG和TIFF图形设备

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Graphics devices for BMP, JPEG, PNG and TIFF format bitmap files.
JPEG,BMP,PNG和TIFF格式的位图文件的图形设备。


用法----------Usage----------


bmp(filename = "Rplot%03d.bmp",
    width = 480, height = 480, units = "px", pointsize = 12,
    bg = "white", res = NA, family = "", restoreConsole = TRUE,
    type = c("windows", "cairo"), antialias)

jpeg(filename = "Rplot%03d.jpg",
     width = 480, height = 480, units = "px", pointsize = 12,
     quality = 75,
     bg = "white", res = NA, family = "", restoreConsole = TRUE,
     type = c("windows", "cairo"), antialias)

png(filename = "Rplot%03d.png",
    width = 480, height = 480, units = "px", pointsize = 12,
    bg = "white", res = NA, family = "", restoreConsole = TRUE,
    type = c("windows", "cairo", "cairo-png"), antialias)

tiff(filename = "Rplot%03d.tif",
     width = 480, height = 480, units = "px", pointsize = 12,
     compression = c("none", "rle", "lzw", "jpeg", "zip"),
     bg = "white", res = NA, family = "", restoreConsole = TRUE,
     type = c("windows", "cairo"), antialias)



参数----------Arguments----------

参数:filename
the name of the output file, up to 511 characters.  The page number is substituted if a C integer format is included in the character string, as in the default, and tilde-expansion is performed (see path.expand).   (The result must be less than 600 characters long.  See postscript for further details.)  
输出文件的名称,最多511个字符。如果在字符串中包含一个C整数格式,页码被取代,因为在默认,执行和波浪线膨胀(见path.expand)。 (结果必须小于600个字符长。见postscript为进一步的细节。)


参数:width
the width of the device.
设备的宽度。


参数:height
the height of the device.
设备的高度。


参数:units
The units in which height and width are given.  Can be px (pixels, the default), in (inches), cm or mm.
所在单位height和width给出。可以px(像素,默认),in(英寸),cm或mm。


参数:pointsize
the default pointsize of plotted text, interpreted as big points (1/72 inch) at res ppi.
绘制文本的默认的pointsize,解释resPPI(1/72英寸)大点。


参数:bg
the initial background colour: can be overridden by setting par("bg").
初始背景颜色:可以通过设置标准杆(“BG”)重写。


参数:quality
the "quality" of the JPEG image, as a percentage.  Smaller values will give more compression but also more degradation of the image.
质的JPEG图像,以百分比。较小的值将给予更多的压缩,但也更多的图像退化。


参数:compression
the type of compression to be used.
要使用的压缩类型。


参数:res
The nominal resolution in ppi which will be recorded in the bitmap file, if a positive integer.  Also used for units other than the default.  If not specified, taken as 72 ppi to set the size of text and line widths.
在PPI的标称分辨率将位图文件中的记录,如果一个正整数。也可用于其他单位比默认。如果没有指定,为72 ppi的设置大小的文字和线条宽度。


参数:family
A length-one character vector specifying the default font family.  The default means to use the font numbers on the Windows GDI versions and "sans" on the cairographics versions.
长度指定的默认字体家族的一个特征向量。默认是指使用在Windows GDI版本和"sans"cairographics版本的字体。


参数:restoreConsole
See the "Details" section of windows.  For type == "windows" only.
见“详细资料”部分windows。 type == "windows"只。


参数:type
Should be plotting be done using Windows GDI or cairographics?
应图使用的Windows GDI或cairographics?


参数:antialias
Length-one character vector.  For allowed values and their effect on fonts with type =       "windows" see windows: for that type if the argument is missing the default is taken from windows.options()$bitmap.aa.win.  For allowed values and their effect (on fonts and lines) with type = "cairo" see svg.
长度的一个特征向量。为允许值和其效果与字体type =       "windows"看到windows:这种类型的,如果缺少参数默认是从windows.options()$bitmap.aa.win。对于允许值和type = "cairo"看到svg其效果(字体和线条)。


Details

详情----------Details----------

Plots in PNG and JPEG format can easily be converted to many other bitmap formats, and both can be displayed in modern web browsers.  The PNG format is lossless and is best for line diagrams and blocks of colour.  The JPEG format is lossy, but may be useful for image plots, for example.  The BMP format is standard on Windows, and supported by most viewers elsewhere.  TIFF is a meta-format: the default format written by tiff is lossless and stores RGB values uncompressed—such files are widely accepted, which is their main virtue over PNG.
PNG和JPEG格式的图可以很容易地转换为许多其他的位图格式,既可以在现代的Web浏览器显示。 PNG格式是无损的,是最好的线路图和色块。 JPEG格式是有损的,但可能是有用的,例如图像图。 BMP格式是Windows上的标准,和其他地方的大多数观众的支持。 TIFF是一种元格式:tiff书面的默认格式是无损和商店的RGB值等未压缩的文件已被广泛接受,这是对巴新的主要凭借。

Windows GDI imposes limits on the size of bitmaps: these are not documented in the SDK and may depend on the version of Windows. It seems that width and height are each limited to 2^15-1.  In addition, there are limits on the total number of pixels which depend on the graphics hardware.
Windows的GDI对位图的大小限制:这些都不是记录在SDK可能取决于Windows版本。它似乎width和height是2^15-1每个有限。此外,还有上依赖于图形硬件的像素总数的限制。

By default no resolution is recorded in the file.  Viewers will often assume a nominal resolution of 72 ppi when none is recorded.  As resolutions in PNG files are recorded in pixels/metre, the reported ppi value will be changed slightly.
默认情况下,没有解决被记录在档案中。没有记录时,观众往往会假定标称分辨率为72 ppi。作为PNG文件中的决议像素/米的记录,报告的PPI值将略有改变。

For graphics parameters that make use of dimensions in inches, res ppi (default 72) is assumed.
对于图形参数,使英寸的尺寸,res PPI(默认72)假设。

Both bmp and png will use a palette if there are fewer than 256 colours on the page, and record a 24-bit RGB file otherwise. For the png device, type = "cairo" does the PNG output in the driver and so is compatible with the "windows" type. type = "cairo-png" uses cairographics' PNG backend which will never use a palette and normally creates a larger 32-bit ARGB file—this may work better for specialist uses with semi-transparent colours.
既bmp和png将使用一个调色板,如果有不少于256页的颜色,否则记录24位RGB文件。 png设备,type = "cairo"在驱动程序中的PNG输出等"windows"类型兼容。 type = "cairo-png"使用cairographics“PNG后端绝不会使用一个调色板,通常创建一个更大的32位ARGB文件,这可能专科采用半透明的颜色更好。

png(type = "windows") supports transparent backgrounds on 16-bit ("High Color") or better screens: use bg =     "transparent".  There is also support for semi-transparent colours of lines, fills and text.  However, as there is only partial support for transparency in the graphics toolkit used: if there is a transparent background semi-transparent colours are painted onto a slightly off-white background and hence the pixels are opaque.
png(type = "windows")支持透明背景:16位(“高彩”)或更好的屏幕上使用bg =     "transparent"。也有支持半透明的线条颜色,填充和文本。然而,由于只有部分支持的图形工具使用的透明度:如果有一个透明的背景半透明的颜色涂上略有白色背景,因此像素是不透明的。

Not all PNG viewers render files with transparency correctly.
并非所有的PNG观众提供正确文件与透明度。


值----------Value----------

A plot device is opened: nothing is returned to the R interpreter.
剧情设备被打开:没有返回到R解释。


警告----------Warnings----------

Note that by default the width and height values are in pixels not inches.  A warning will be issued if both are less than 20.
请注意,默认情况下,width和height值的像素不英寸。如果两者都小于20,将发出一个警告。

If you plot more than one page on one of these devices and do not include something like %d for the sequence number in file, the file will contain the last page plotted.
如果你积多个页面,这些设备之一,不包括像%dfile,该文件将包含序列号的最后一页绘制的东西。


与操作系统的差异----------Differences between OSes----------

These functions are interfaces to three or more different underlying devices.
这些功能是三个或更多不同的底层设备的接口。

On Windows, devices based on plotting to a hidden screen using Windows' GDI calls.
在Windows中,设备的基础上绘制一个隐藏的屏幕,使用Windows的GDI调用。

On platforms with support for X11, plotting to a hidden X11 display.
上为X11的支持平台,策划一个隐藏的X11显示。

On Mac OS X when working at the console and when R is compiled with suitable support, using Apple's Quartz plotting system.
Mac OS X上工作时,在控制台,当R编译适当的支持,使用苹果的Quartz绘图系统。

Where support has been compiled in for cairographics, plotting on cairo surfaces.  This may use the native platform support for fonts, or it may use fontconfig to support a wide range of font formats.  (This was first available on Windows in R 2.14.0.)
支持已被编译为cairographics,在开罗表面绘制。这可以使用本地平台支持字体,或者它可以使用fontconfig支持多种字体格式。 (这是首次在R 2.14.0在Windows上使用。)

Inevitably there will be differences between the options supported and output produced.  Perhaps the most important are support for antialiased fonts and semi-transparent colours: the best results are likely to be obtained with the cairo- or Quartz-based devices where available.
难免会有支持和输出产生的选项之间的差异。也许最重要的是支持抗锯齿字体和颜色半透明:最好的结果很可能将在开罗或石英为基础的装置可用获得。

The default extensions are ".jpg" and ".tif" on Windows, and ".jpeg" and ".tiff" elsewhere.
默认扩展名是“.jpg和.tif”在Windows上,和.jpeg和.tiff“在别处。


公约----------Conventions----------

This section describes the implementation of the conventions for graphics devices set out in the “R Internals Manual”.
本节介绍的“R内部手册”所载的图形设备的公约的执引号况。

The default device size is in pixels.
默认设备的大小,以像素为单位。

Font sizes are in big points interpreted at res ppi.
字体大小大点resPPI解释。

The default font family is Arial.
默认字体是Arial。

Line widths are a multiple of 1/96 inch (interpreted at res ppi), with a minimum of one pixel (type =       "windows") or 0.01 (type = "cairo").
线的宽度的1/96英寸的(resPPI解释)多个,最小的一个像素(type =       "windows")或0.01(type = "cairo")。

The minimum radius of a circle is 1 pixel for type =       "windows".
最小圆的半径为1像素type =       "windows"。

Colours are interpreted by the viewing application.
颜色被解释通过查看应用程序。


注意----------Note----------

The type = "windows" versions of these devices effectively plot on a hidden screen and then copy the image to the required format.  This means that they have the same colour handling as the actual screen device, and work best if that is set to a 24-bit or 32-bit colour mode.
type = "windows"这些设备有效地积版本上一个隐藏的屏幕上,然后复制到所需的格式的图像。这意味着,他们有实际屏幕设备相同的颜色处理,效果最好,如果设置为24位或32位色彩模式。

For high-quality plots you will probably want antialias =     "cleartype" if this is not the default on your Windows system.  On the other hand, png(antialias = "none") will give the most compact files
对于高品质的图,你可能会想antialias =     "cleartype"如果这不是您的Windows系统的默认。另一方面,png(antialias = "none")会给最紧凑的文件


参见----------See Also----------

Devices, dev.print
Devices,dev.print

bitmap provides an alternative way to generate plots in many bitmap formats if GhostScript is available.
bitmap提供了一种替代的方式来生成在许多位图格式的图,如果Ghostscript是可用。


举例----------Examples----------


## copy current plot to a (large) PNG file[#(大)PNG文件复制当前的图]
## Not run: dev.print(png, file = "myplot.png", width = 1024, height = 768)[#无法运行:dev.print(PNG,文件“myplot.png”= 1024,宽度,高度= 768)]

png(file = "myplot.png", bg = "transparent")
plot(1:10)
rect(1, 5, 3, 7, col = "white")
dev.off()

jpeg(file = "myplot.jpeg")
example(rect)
dev.off()


转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-1-23 01:12 , Processed in 0.023715 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表