I would like to build a faceted graph ggplot2. the x axis is continuous, the y axis is a list of animals. Two variables are constructed and faceted according to the behavior of the food.
The y-axis is on a free scale because each animal appears in only one category of behavior in food.
library(ggplot2)
msleep.noNA <- msleep[!is.na(msleep$vore),]
msleep.noNA.red <- msleep.noNA[c(1,3,6,7)]
msleep.noNA.red <- msleep.noNA.red[!is.na(msleep.noNA.red[4]),]
msleep.noNA.red <- melt(msleep.noNA.red)
pg <- ggplot(msleep.noNA.red, aes(value, name, colour = variable)) +
geom_point() +
facet_grid(vore ~ ., scale="free_y", space = "free_y")
pg
pg + scale_y_reverse()
class(msleep.noNA.red$name)
Does anyone have any clues as to how I can make a list of animal names in alphabetical order on each subplot?
source
share