# Example figures for incubations for PA
# Load libraries
library(ggplot2)
library(reshape)
## Loading required package: plyr
##
## Attaching package: 'reshape'
##
## Les objets suivants sont masqués from 'package:plyr':
##
## rename, round_any
# Create data
data <- data.frame(stream = c(rep(x = "A", times = 4), rep(x = "B", times = 4)),
trt = rep(x = c("light", "dark"), times = 8), inoc = c(rep(x = "Y", times = 2),
rep(x = "N", times = 2)), time = c(rep(x = 0, times = 8), rep(x = 1,
times = 8)), CO2 = c(rep(x = 100, times = 8), rep(x = 200, times = 8)) *
runif(16) * 10, CH4 = c(rep(x = 5, times = 8), rep(x = 5, times = 8)) *
runif(16) * 10, N2O = c(rep(x = 10, times = 8), rep(x = 10, times = 8)) *
runif(16) * 1)
# Figure faceted by inonculations (y)
ggplot(data, aes(x = time, y = CO2, shape = stream, colour = trt)) + geom_point() +
geom_line() + facet_grid(inoc ~ .)
# Figure faceted by inonculations (y) and stream (x)
ggplot(data, aes(x = time, y = CO2, colour = trt)) + geom_point() + geom_line() +
facet_grid(inoc ~ stream)
# Need to melt to plot all gases together via faceting (note variable in
# facet)
data.melt <- melt(data, id = c("time", "stream", "trt", "inoc"))
ggplot(data.melt, aes(x = time, y = value, shape = stream, colour = trt)) +
geom_point() + geom_line() + facet_grid(inoc ~ variable)