• R 画图保存为文件


    ========================

    pdf("h20.pdf",width =6,height = 5 )
    plot ...
    dev.off()

    ========================

    第一种png格式
    png(file="myplot.png", bg="transparent")
    画图程序
    dev.off()

     
    ========================

    第二种jpeg格式
    jpeg(file="myplot.jpeg")
    画图程序
    dev.off()
    文件都放在getwd()里了

     
    ========================

    第三种pdf格式
    pdf(file="myplot.pdf")
    画图程序
    dev.off()

     
    ========================

    下面是一个具体的例子
    png(file="myplot.png", bg="transparent")
    plot(1:10)
    rect(1, 5, 3, 7, col="white")
    dev.off()
    所有文件都放在getwd()里面了,你只需输入
    getwd()
    就可以看到文件所在位置

    ========================
     

    Description

    Graphics devices for BMP, JPEG, PNG and TIFF format bitmap files.

    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", "lzw+p", "zip+p"),
         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.)

    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.

    pointsize

    the default pointsize of plotted text, interpreted as big points (1/72 inch) at res ppi.

    bg

    the initial background colour: can be overridden by setting par("bg").

    quality

    the ‘quality’ of the JPEG image, as a percentage. Smaller values will give more compression but also more degradation of the image.

    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.

    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.

    restoreConsole

    See the ‘Details’ section of windows. For type == "windows" only.

    type

    Should be plotting be done using Windows GDI or 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, but not fills) with type = "cairo" see svg.

     
     
     
    REF
    https://blog.csdn.net/fengziyun/article/details/7757779?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.pc_relevant_is_cache&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.pc_relevant_is_cache
     
  • 相关阅读:
    Adobe Creative Cloud for Win 解决:应用程序无法正常启动(0x0000022)。请单击“确定”关闭应用程序
    项目管理 PM 第六章 时间管理
    R for mac安装 无法争取安装Unable to install any packages 安装 r 里的 igraph 报错 ERROR: configuration failed for package ‘igraph’
    Python 相对路径的解决 “Unicode Error ”unicodeescape" codec can't decode bytes… Cannot open text files in Python 3
    GraphML入门教程
    文案——编辑——希腊字母Greek Alphabet
    Tensorflow入门
    安装Tensorflow及安装过程中的错误——ModuleNotFoundError: No module named 'tensorflow'
    基于 Virtualenv 的安装Tensorflow
    小程序--腾讯地图导航
  • 原文地址:https://www.cnblogs.com/emanlee/p/13911649.html
Copyright © 2020-2023  润新知