#' GWS Power Spectrum Comparison Plot
#'
#' @param wgen_wave output of wavelet analysis of historical data generated by wavelet_analysis()
#' @param wgen_mc output of monte carlo simulation of arimas generated by arimas_monte()
#' @export
plot_gws_power <- function(wgen_wave, wgen_mc) {
x1 <- 1
x2 <- min(nrow(wgen_mc$gws.stat), length(wgen_wave$period))
df_area <- data.frame(PERIOD=wgen_wave$period[x1:x2],
Q025=wgen_mc$gws.stat[x1:x2, 'Q025'],
Q975=wgen_mc$gws.stat[x1:x2, 'Q975'])
df_lines <- data.frame(PERIOD=wgen_wave$period[x1:x2],
POWER=wgen_wave$gws[x1:x2],
MEAN=wgen_mc$gws.stat[x1:x2, 'MEAN'],
SIGNIF=wgen_wave$gws.sig$signif[x1:x2])
df_lines <- tidyr::gather(df_lines, VAR, VALUE, POWER:SIGNIF)
p <- ggplot2::ggplot(df_lines, aes(x=PERIOD)) +
ggplot2::geom_ribbon(aes(ymin=Q025, ymax=Q975), data=df_area, fill='grey80') +
ggplot2::geom_line(aes(y=VALUE, color=VAR, linetype=VAR)) +
ggplot2::scale_color_manual('', values=c('MEAN'='blue', 'POWER'='black', 'SIGNIF'='red'), labels=c('MEAN'='Mean', 'POWER'='Historical', 'SIGNIF'='Signif Level')) +
ggplot2::scale_linetype_manual('', values=c('MEAN'=2, 'POWER'=1, 'SIGNIF'=2), labels=c('MEAN'='Mean', 'POWER'='Historical', 'SIGNIF'='Signif Level')) +
ggplot2::scale_y_log10(labels=scales::comma) +
ggplot2::labs(x="Fourier Period (yr)", y="Global Wave Spectrum Power") +
ggplot2::theme_bw() +
ggplot2::theme(legend.position=c(0, 0), legend.justification=c(0, 0))
p
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.