qplot pie instalar ggplot como chart barplot r ggplot2

pie - qplot y anti-aliasing en R



pie chart r ggplot2 (4)

En Windows, no hay anti-aliasing incorporado. No sé si está previsto para futuras versiones o no. Puede obtener un dispositivo gráfico basado en Cairo desde los paquetes cairoDevice o Cairo ; Sin embargo, primero deberá instalar GTK+ :

Descargue e instale Gtk+ 2.12.9 Runtime Environment Revision 2 de http://gladewin32.sourceforge.net/

Otra opción sería usar gráficos basados ​​en Java a través de JGR ( http://jgr.markushelbig.org/ ). También un dispositivo basado en Qt está en desarrollo, creo.

Estoy usando la biblioteca ggplot2 y estoy trabajando con el comando qplot Sé que puedo guardar mi salida como un archivo de imagen antialias utilizando el siguiente comando después de mi qplot

ggsave(file="filename.png")

Pero ¿qué hay de mi pantalla LCD? ¿Hay alguna manera de ver un diagrama en el monitor como grpah anti-aliased?


Ok, acabo de comprobar. Me equivoqué en mi comentario anterior. Desde la help(x11) donde hay muchos detalles disponibles: los nuevos dispositivos basados ​​en El Cairo tienen anti-aliasing disponible:

paquete x11: documentación grDevices R

Gráficos del sistema X Window

Descripción:

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

Uso:

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

Argumentos:

[...]

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

[...]

Detalles:

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.

[...y más...]


Como otros han mencionado, el dispositivo gráfico de Windows incorporado de R no hace anti-aliasing. Pero hoy en día es fácil instalar el dispositivo gráfico de Cairo, que sí lo hace.

En la consola R:

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

Probar:

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

Más


Si tiene instalado Cairo (consulte las otras respuestas), para guardarlo como PNG antialias, simplemente cambie su código a:

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

como se especifica aquí .

Pero, ¿con qué propósito quieres "ver un diagrama en el monitor como gráfico antialiasado" o "anti-alias mis ventanas de trazado"? Si quiere decir que en la ventana Plots (pestaña) en RStudio, no estoy seguro de que se pueda hacer, sirve básicamente como una vista previa. Le sugiero que guarde el gráfico en un archivo y luego use este archivo para mostrarlo o para cualquier otro propósito.