watercolor plots

R has been recognised as the most powerful statistical tool for displaying graphs. In the last years, R’s awesomeness in depicting relationships between variables is exploding with great packages such as ggplot2. One can simply walk around some R blogs, and find something like this:

The ‘watercolor‘ plot (aka à la Solomon Hsiang).

Once you click these links above, you will forget completely about my blog, so… wait! I have to show a graph I made with the code provided there! Here it is, isn’t beautiful?

The ‘aurora’ plot:
Imagen

This black background is a little tweak from the plain one… Here’s the line of code I modified from the original of Felix Schönbrodt:

# you can change this line:

gg.points <- geom_point(data=data, aes_string(x=IV, y=DV), size=1, shape=shape, fill="white", color="black")

# for this one (you can tweak more parameters in it like the size of the points):

gg.points <- geom_point(data=data, aes_string(x=IV, y=DV), size=1, shape=shape, fill="white", color="white")

# then I run the function adding my black background (surrounded by a white background):

p <- vwReg(......, shape = 21, ......)

p + theme(
panel.background = element_rect(fill = "black",colour = NA),
panel.grid.minor = element_line("gray28", size = 0.1),
panel.grid.major = element_line("gray48", size = 0.1),
plot.background = element_rect(fill = "white",colour = NA))

And another one, in white background.. (and spaghetti = TRUE)

spaghetti_scores

2 pensamientos en “watercolor plots

  1. Thanks for creating the nice figures! May I ask where it is possible to hide data points and only keep the watercolor regression line?

    • Hi,
      I would suggest to take a look at the original code, line 198:

      gg.elements <- list(gg.tiles, gg.poly, gg.spag, gg.median, gg.CI1, gg.CI2, gg.lm, gg.points, gg.title, theme(legend.position="none"))

      Here, you can modify the function deleting the object "gg.points". The function will print all the elements, except this one.
      Hth

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s