Nothing
#' Chamber: Plotting Diurnal Profile
#'
#' A function to plot the diurnal patterns of environmental variables.
#'
#' @param display a character string, which plots to display.
#' @param x a data frame, output of \code{\link{chamber.diurnal}}.
#' @param ... additional arguments, currently ignored.
#'
#' @returns a six-panel plot of environmental variables.
#' @method plot chamber.diurnal
#' @export
#'
#' @examples
#' # default
#' day0 <- chamber.diurnal()
#' plot(day0)
#' plot(day0, display = "light")
#' plot(day0, display = "immersion")
#' plot(day0, display = "temp")
plot.chamber.diurnal <- function(x, ...,
display = c("all", "light", "immersion", "temperature")){
df <- x
temp.breaks <- pretty(range(df$temp.air, df$temp.water))
temp.breaks.range <- range(temp.breaks)
hour.breaks <- seq(0, 24, 6)
fig1 <- ggplot(df, aes(x = .data$hour, y = .data$light)) +
geom_step(color = 1, linetype = 2) +
geom_point(color = 7) + # color = 7
# geom_line(linetype = 2) + # normal curve
scale_x_continuous(breaks = hour.breaks) +
scale_y_continuous(limits = c(0, 100)) +
labs(title = "Light", y = "%", x = "") +
theme_minimal_grid()
fig2 <- ggplot(df, aes(x = .data$hour, y = .data$temp.air)) +
geom_line(color = 1, linetype = 2) +
geom_point(color = 2, shape = 17) + # color = 2
scale_x_continuous(breaks = hour.breaks) +
scale_y_continuous(breaks = temp.breaks, limits = temp.breaks.range) +
labs(title = "Air temperature", y = "\u00B0C", x = "") +
theme_minimal_grid()
fig3 <- ggplot(df, aes(x = .data$hour, y = .data$temp.water)) +
geom_line(color = 1, linetype = 2) +
geom_point(color = 2, shape = 15) + #color = 2
scale_x_continuous(breaks = hour.breaks) +
scale_y_continuous(breaks = temp.breaks, limits = temp.breaks.range) +
labs(title = "Water temperature", y = "\u00B0C", x = "") +
theme_minimal_grid()
fig4 <- ggplot(df, aes(x = .data$hour, y = .data$immersion)) +
geom_step(color = 1, linetype = 2) +
geom_point(color = 4) + #color = 4
scale_x_continuous(breaks = hour.breaks) +
scale_y_continuous(breaks = c(0, 1), limits = c(0, 1)) +
labs(title = "Immersion", y = NULL, x = "") +
theme_minimal_grid()
fig5 <- ggplot(df, aes(x = .data$hour, y = .data$temp)) +
geom_line(color = 1, linetype = 2) +
geom_point(color = 2, aes(shape = as.factor(.data$immersion))) + #color = 2
scale_shape_manual(values = c(17, 15)) +
scale_x_continuous(breaks = hour.breaks) +
scale_y_continuous(breaks = temp.breaks, limits = temp.breaks.range) +
labs(title = "Exposure temperature", y = "\u00B0C", x = "Time of day (h)") +
theme_minimal_grid() +
theme(legend.position = "none")
fig6 <- ggplot(df, aes(x = .data$hour, y = .data$wc)) +
geom_step(color = 1, linetype = 2) +
geom_point(color = 1) + #color = 8
scale_x_continuous(breaks = hour.breaks) +
scale_y_continuous(breaks = c(0, 1), limits = c(0, 1)) +
labs(title = "Water change", y = NULL, x = "") +
theme_minimal_grid()
display <- match.arg(display)
if (display == "all") {
output <- plot_grid(fig1, fig2, fig3, fig4, fig5, fig6,
align = "hv")
} else if (display == "light") {
output <- fig1 + labs(x = "Time of day (h)")
} else if (display == "immersion") {
output <- fig4 + labs(x = "Time of day (h)")
} else if (display == "temperature") {
output <- plot_grid(fig2, fig3, fig4, fig5,
align = "hv")
}
output
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.