#' create contour plots
#'
#' @param dfIN: ["X","Y","C","f"] Where names of dataframe columns are used to label the axes, color scale. "f" is facet variable.
#' Note: color scale will be in log10, meant for dispersion gradients.
#'
#' @return ggplot object
#'
#' @import ggplot2
#'
#' @export mgsplot.contour
#########################################################################
mgsplot.contour <- function(df){
IN_names <- colnames(df)
x_lab <- IN_names[1]
y_lab <- IN_names[2]
c_lab <- IN_names[3]
plotdf <- df[,1:4]
colnames(plotdf) <- c("x","y","C","f")
p <- ggplot(plotdf, aes(x, y)) + geom_tile(aes(fill=C)) +
xlab(x_lab) + ylab(y_lab) + # labs(title=name) +
scale_fill_gradientn(colours = rev(rainbow(4)),name= paste(c_lab,'(ug/m3)',sep=" "),trans = "log10") +
facet_grid(f~.,scales="free",space="free") +
theme(strip.text.y = element_text(angle = 0))
return(p)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.