knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(MCE) library(dplyr)
data.frame(Light = seq(0.0065, 1, length = 500)) %>% # Choose light levels mutate("Bright depths" = depth(Light), # Calculate depths "Shaded depths" = depth(Light, shade = 0.25), # Calculate depths "Shallow community" = shallow(Light), "Mesophotic community" = mesophotic(Light), "Whole reef" = reef(Light)) -> depth.distribution # Calculate community values
knitr::kable(depth.distribution[1:5,], format="html") %>% kableExtra::kable_styling(bootstrap_options = "striped", full_width = T)
boundaries <- data.frame(Boundary = c("lower", "upper"), Depth = c(depth(reef_boundary()), depth(reef_boundary(), shade = 0.25)))
knitr::kable(boundaries, format="html") %>% kableExtra::kable_styling(bootstrap_options = "striped", full_width = T)
library(ggplot2) ggplot(depth.distribution, aes(y= `Bright depths`, x= `Whole reef`)) + annotate("rect", xmin=-1,xmax=0, ymin=-Inf, ymax=Inf, fill="steelblue2", alpha=0.75)+ # Box from -1 to 0 annotate("rect", xmin=0, xmax=1, ymin=-Inf, ymax=Inf, fill="tan2", alpha=0.75)+ # Box from 0 to 1 geom_ribbon(data = depth.distribution, aes(ymin = `Shaded depths`, ymax = `Bright depths`, x= `Whole reef`), colour = 'white', fill = 'White', alpha = 0.45) + # Add model range geom_point(data = boundaries, aes(x = 0, y = Depth)) + scale_y_reverse() + coord_cartesian(ylim = c(100, 0), xlim = c(-0.65,0.65)) + annotate("text", label="Shallow", y=93, x=-0.35, col="Black")+ annotate("text", label="observations", y=100, x=-0.35, col="Black")+ annotate("text", label="Mesophotic", y=93, x=0.35, col="Black")+ annotate("text", label="observations", y=100, x=0.35, col="Black")+ theme_minimal() + theme(plot.title = element_text(size=12, hjust = 0.5), axis.title.x = element_text(size=10), axis.title.y = element_text(size=10), legend.position = 'bottom') + # label sizes and legend position NULL
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.