Domanda

Sto usando biblioteca ggplot2 e sto lavorando con il comando qplot So che posso salvare il mio output come un file immagine anti-aliasing utilizzando il seguente comando dopo il mio qplot

ggsave(file="filename.png")

Ma come circa il mio display LCD? non v'è alcun modo per vedere un grafico sul monitor come grpah anti-aliasing?

È stato utile?

Soluzione

In Windows, non v'è alcun built-in anti-aliasing. Non so se è in programma per le versioni future o meno. È possibile ottenere un dispositivo grafico con sede al Cairo da entrambi i pacchetti cairoDevice o Cairo; tuttavia, sarà necessario installare prima GTK+:

Scaricare e installare Gtk+ 2.12.9 Runtime Environment Revision 2 da http://gladewin32.sourceforge.net/

Un'altra opzione sarebbe quella di utilizzare la grafica basati su Java attraverso JGR (http://jgr.markushelbig.org/). Anche un dispositivo Qt-based è in fase di sviluppo, penso.

Altri suggerimenti

Come altri hanno detto, built-in di Windows dispositivo grafico di R non fa l'anti-aliasing. Ma al giorno d'oggi è facile da installare il dispositivo grafico del Cairo che fa.

Al console R:

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

Per prova:

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

Più

Se avete installato Cairo (vedere le altre risposte), per salvarlo come PNG anti-aliasing, basta modificare il codice per:

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

qui .

Ma per quale scopo vuoi "vedere un grafico sul monitor come grafico di anti-aliasing" o "anti-alias mie finestre trama"? Se vuoi dire come nella finestra Terreni (scheda) in RStudio, non sono sicuro che si possa fare, serve fondamentalmente solo come anteprima. Vi suggerisco di salvare il grafico in un file e quindi utilizzare questo file per visualizzarlo o per qualsiasi altro scopo.

Ok, ho appena controllato. Ho sbagliato nel mio precedente commento. Da help(x11) dove un sacco di dettaglio è disponibile - i nuovi dispositivi con sede al Cairo hanno l'anti-aliasing a disposizione:

  

pacchetto x11: grDevices   R Documentation

     

X Window System Grafica

     

Descrizione:

 ‘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’.
     

Utilizzo:

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

 X11.options(..., reset = FALSE)
     

Argomenti:

     

[...]

 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")’. 
     

[...]

     

dettagli:

 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. 
     

[... e molto altro ancora ...]

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top