代码之家  ›  专栏  ›  技术社区  ›  Mark

qplot与R中的抗混叠

  •  17
  • Mark  · 技术社区  · 16 年前

    ggsave(file="filename.png")
    

    但是我的液晶显示器呢?有没有办法将监视器上的绘图视为抗锯齿grpah?

    4 回复  |  直到 16 年前
        1
  •  14
  •   Felix Andrews    16 年前

    在Windows上,没有内置的抗锯齿功能。我不知道它是否计划在未来发布。您可以从以下任一位置获得基于Cairo的图形设备: cairoDevice 或 Cairo 包装;但是,您需要安装 GTK+

    下载并安装 Gtk+ 2.12.9 Runtime Environment Revision 2 从…起 http://gladewin32.sourceforge.net/

    另一种选择是通过以下方式使用基于Java的图形: JGR ( http://jgr.markushelbig.org/ ). 也是 Qt -我认为,基于网络的设备正在开发中。

        2
  •  16
  •   jwfearn    14 年前

    正如其他人提到的,R的内置Windows图形设备不进行抗锯齿。但是现在安装Cairo图形设备很容易,因为它确实可以。

    在R控制台上:

    install.packages('Cairo',,'http://www.rforge.net/')
    

    plot(rnorm(1000)) # non-antialiased (on Windows)
    library('Cairo')
    CairoWin()
    plot(rnorm(1000)) # antialiased!
    

    More

        3
  •  5
  •   Melkor.cz    11 年前

    如果已安装Cairo(请参阅其他答案),要将其保存为抗锯齿PNG,只需将代码更改为:

    ggsave(file="filename.png", type="cairo-png")

    按规定 here

    但是,您希望“将监视器上的绘图视为抗锯齿图形”或“抗锯齿我的绘图窗口”的目的是什么?如果你的意思是像RStudio中的Plots窗口(选项卡)一样,我不确定这是否可以完成,它基本上只是一个预览。我建议您将图形保存到一个文件中,然后使用此文件显示它或用于任何其他目的。

        4
  •  4
  •   Dirk is no longer here    16 年前

    好的,我刚查过。我先前的评论是错误的。从…起 help(x11)

    x11封装:GR器件 R文件

    X窗口系统图形

    说明:

     ‘X11’ starts a graphics device driver for the X Window System
     (version 11).  This can only be done on machines/accounts that
     have access to an X server.
    
     ‘x11’ is recognized as a synonym for ‘X11’.
    

    用法:

     X11(display = "", width, height, pointsize, gamma, bg, canvas,
         fonts, xpos, ypos, title, type, antialias)
    
     X11.options(..., reset = FALSE)
    

    [...]

     fonts: X11 font description strings into which weight, slant and
          size will be substituted.  There are two, the first for fonts
          1 to 4 and the second for font 5, the symbol font.  See
          section ‘Fonts’. 
    

    [...]

     antialias: for cairo types, the typeof anti-aliasing (if any) to be
          used.  One of ‘c("default", "none", "gray", "subpixel")’. 
    

    [...]

    细节:

     The defaults for all of the arguments of ‘X11’ are set by
     ‘X11.options’: the ‘Arguments’ section gives the ‘factory-fresh’
     defaults.
    
     The initial size and position are only hints, and may not be acted
     on by the window manager.  Also, some systems (especially laptops)
     are set up to appear to have a screen of a different size to the
     physical screen.
    
     Option ‘type’ selects between two separate devices: R can be built
     with support for neither, ‘type = "Xlib"’ or both.  Where both are
     available, types ‘"cairo"’ and ‘"nbcairo"’ offer
    
        * antialiasing of text and lines.
    
        * translucent colours.
    
        * scalable text, including to sizes like 4.5 pt.
    
        * full support for UTF-8, so on systems with suitable fonts you
          can plot in many languages on a single figure (and this will
          work even in non-UTF-8 locales).  The output should be
          locale-independent.
    
     ‘type = "nbcairo"’ is the same device as ‘type="cairo"’ without
     buffering: which is faster will depend on the X11 connection.
     Both will be slower than ‘type = "Xlib"’, especially on a slow X11
     connection as all the rendering is done on the machine running R
     rather than in the X server.
    
     All devices which use an X11 server (including the ‘type = "Xlib"’
     versions of bitmap devices such as ‘png’) share internal
     structures, which means that they must use the same ‘display’ and
     visual.  If you want to change display, first close all such
     devices. 
    

    [……还有更多……]