I am currently working on a graph with ggplot2 in R where I want to use facet_wrap to create 5 subplots.
Here is my code so far:
# getting the data
data = structure(list(type = c("red", "blue", "orange", "yellow", "green",
"red", "blue", "orange", "yellow", "green", "red", "blue", "orange",
"yellow", "green", "red", "blue", "orange", "yellow", "green"),
cond = c("new", "new", "new", "new", "new", "old", "old",
"old", "old", "old", "new", "new", "new", "new", "new", "old",
"old", "old", "old", "old"), fact = c("light", "light", "light",
"light", "light", "light", "light", "light", "light", "light",
"shiny", "shiny", "shiny", "shiny", "shiny", "shiny", "shiny",
"shiny", "shiny", "shiny"), score = c(2L, 4L, 8L, 6L, 10L, 3L,
5L, 9L, 1L, 3L, 12L, 14L, 18L, 16L, 20L, 13L, 15L, 19L, 11L,
13L)), class = "data.frame", row.names = c(NA, -20L))
library(ggplot2)
ggplot(data=data, aes(x=cond, y=score, fill=fact)) +
geom_bar(stat="identity", position=position_dodge()) +
theme_bw() + facet_wrap(. ~ type, ncol=3)
This creates the following plot:
However, since one of the colours is much more important than the others, I would like to create one of these options:
Does anyone know how to get facet_wrap to do that or can point me to another option to create this?
Cheers, Max



