Skip to content

Commit

Permalink
replace gridExtra with patchwork, addl text edits
Browse files Browse the repository at this point in the history
  • Loading branch information
fawda123 committed Jan 2, 2024
1 parent c0d0355 commit f79a265
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
# any::here
# any::tibble
# any::ggplot2
# any::gridExtra
# any::patchwork
# any::Hmisc
# any::tinytex
# any::pdftools
Expand Down
Binary file modified figure/attainmat.pdf
Binary file not shown.
Binary file modified figure/chlboxplot.pdf
Binary file not shown.
Binary file modified figure/chlmat.pdf
Binary file not shown.
Binary file modified figure/sitemap-1.pdf
Binary file not shown.
Binary file modified figure/sitemap.pdf
Binary file not shown.
Binary file modified figure/thrplot.pdf
Binary file not shown.
Binary file modified wq.pdf
Binary file not shown.
43 changes: 9 additions & 34 deletions wq1.Rnw
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ library(tbeptools)
library(tibble)
library(ggplot2)
library(Hmisc)
library(gridExtra)
library(patchwork)
# remotes::install_github("tbep-tech/tbeptools")
# devtools::load_all('../tbeptools/.')
Expand All @@ -68,13 +68,6 @@ epcdata <- read_importwq(xlsx, download_latest = F)
# epcdata <- read_importwq(xlsx, download_latest = T)
maxyr <- 2023
partialyr <- F
# get legend from an existing ggplot object
g_legend<-function(a.gplot){
tmp <- ggplot_gtable(ggplot_build(a.gplot))
leg <- which(sapply(tmp$grobs, function(x) x$name) == "guide-box")
legend <- tmp$grobs[[leg]]
return(legend)}
@

\title{\Large \Sexpr{maxyr} Tampa Bay Water Quality Assessments}
Expand Down Expand Up @@ -211,34 +204,16 @@ thrthm <- theme(
axis.text.x = element_text(colour = txtcol, angle = 0, size = 14, hjust = 0.5)
)
sclx <- scale_x_continuous(breaks = seq(1975, maxyr, by = 5))
p1 <- show_thrplot(epcdata, bay_segment = "OTB", thr = "chla", yrrng = yrrng, partialyr = partialyr) + sclx + thrthm
p1leg <- g_legend(p1)
p1 <- p1 + theme(legend.positio = 'none')
p2 <- show_thrplot(epcdata, bay_segment = "HB", thr = "chla", yrrng = yrrng, partialyr = partialyr) + sclx + thrthm + theme(legend.position = 'none')
p3 <- show_thrplot(epcdata, bay_segment = "MTB", thr = "chla", yrrng = yrrng, partialyr = partialyr) + sclx + thrthm + theme(legend.position = 'none')
p4 <- show_thrplot(epcdata, bay_segment = "LTB", thr = "chla", yrrng = yrrng, partialyr = partialyr) + sclx + thrthm + theme(legend.position = 'none')
# align
# Get the widths
pA <- ggplot_gtable(ggplot_build(p1))
pB <- ggplot_gtable(ggplot_build(p2))
pC <- ggplot_gtable(ggplot_build(p3))
pD <- ggplot_gtable(ggplot_build(p4))
maxWidth = grid::unit.pmax(pA$widths[2:3], pB$widths[2:3], pD$widths[2:3], pD$widths[2:3])
# Set the widths
pA$widths[2:3] <- maxWidth
pB$widths[2:3] <- maxWidth
pC$widths[2:3] <- maxWidth
pD$widths[2:3] <- maxWidth
p1 <- show_thrplot(epcdata, bay_segment = "OTB", thr = "chla", yrrng = yrrng, partialyr = partialyr) + sclx
p2 <- show_thrplot(epcdata, bay_segment = "HB", thr = "chla", yrrng = yrrng, partialyr = partialyr) + sclx
p3 <- show_thrplot(epcdata, bay_segment = "MTB", thr = "chla", yrrng = yrrng, partialyr = partialyr) + sclx
p4 <- show_thrplot(epcdata, bay_segment = "LTB", thr = "chla", yrrng = yrrng, partialyr = partialyr) + sclx
p <- (guide_area() / (p1 + p2 + p3 + p4)) + plot_layout(ncol = 1, guides = 'collect', heights = unit(c(1, 1), c("cm", "null"))) & thrthm
pdf(here('figure', 'thrplot.pdf'), family = 'serif', height = 9, width = 10.25)
grid.arrange(
p1leg,
arrangeGrob(pA, pB, ncol = 2),
arrangeGrob(pC, pD, ncol = 2),
ncol = 1, heights = c(0.1, 1, 1)
)
p
dev.off()
@

Expand Down
51 changes: 13 additions & 38 deletions wq2.Rnw
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ library(dplyr)
library(knitr)
library(here)
library(tbeptools)
library(gridExtra)
library(patchwork)
library(ggplot2)
# remotes::install_github("tbep-tech/tbeptools")
Expand All @@ -66,13 +66,6 @@ epcdata <- read_importwq(xlsx, download_latest = F)
# epcdata <- read_importwq(xlsx, download_latest = T)
maxyr <- 2023
partialyr <- F
# get legend from an existing ggplot object
g_legend<-function(a.gplot){
tmp <- ggplot_gtable(ggplot_build(a.gplot))
leg <- which(sapply(tmp$grobs, function(x) x$name) == "guide-box")
legend <- tmp$grobs[[leg]]
return(legend)}
@

\begin{document}
Expand Down Expand Up @@ -116,12 +109,12 @@ dev.off()
\begin{column}{.79\linewidth}

\begin{block}{Maintaining Reasonable Assurance \& TMDL Compliance}
\footnotesize On behalf of the Tampa Bay Nitrogen Management Consortium, TBEP submitted the 2022 Reasonable Assurance (RA) Update for the 2017-2021 period to FDEP in December 2022. FDEP concluded that the RA Update satisfied requirements for approval during the next five year period. During 2022, all bay segments met FDEP criteria for chlorophyll. Tampa Bay Nitrogen Management Consortium participants continue to pursue actions that ensure water quality criteria are met for the next RA period from 2022-2026. The second RA annual assessment report for the 2022-2026 period will be submitted in April 2024.
\footnotesize On behalf of the Tampa Bay Nitrogen Management Consortium, TBEP submitted the 2022 Reasonable Assurance (RA) Update for the 2017-2021 period to FDEP in December 2022. FDEP concluded that the RA Update satisfied requirements for approval during the next five year period. During 2023, all bay segments met FDEP criteria for chlorophyll. Tampa Bay Nitrogen Management Consortium participants continue to pursue actions that ensure water quality criteria are met for the next RA period from 2022-2026. The second RA annual assessment report for the 2022-2026 period will be submitted in April 2024.
\end{block}

\begin{block}{\Sexpr{maxyr} Chl-a Monthly Variation Compared to 1974-\Sexpr{maxyr - 1}}
\footnotesize
Chlorophyll-a concentrations were evaluated within the bay on a monthly basis during \Sexpr{maxyr} and compared to prior years' levels (Figure \ref{fig:chlboxplot}). Summer concentrations in Old Tampa Bay were lower in 2022 compared to years prior, which allowed the chlorophyll criteria to be met again similar to 2022. Understanding and mitigating summer blooms of \textit{Pyrodinium bahamense} in OTB continue to be the focus of research and management efforts for improving water quality in OTB.
Chlorophyll-a concentrations were evaluated within the bay on a monthly basis during \Sexpr{maxyr} and compared to prior years' levels (Figure \ref{fig:chlboxplot}). Summer concentrations in Old Tampa Bay were lower in 2023 compared to years prior, which allowed the chlorophyll criteria to be met again similar to 2022. Understanding and mitigating summer blooms of \textit{Pyrodinium bahamense} in OTB continue to be the focus of research and management efforts for improving water quality in OTB.
\end{block}

<<chlboxplot, echo = F, fig = F, include = F, eval = T>>=
Expand All @@ -133,37 +126,19 @@ thrthm <- theme(
axis.title = element_blank(),
plot.title = element_text(size = 15, colour = txtcol),
legend.text = element_text(size = 12, colour = txtcol),
axis.text.x = element_text(size = 10, colour = txtcol, angle = 0, hjust = 0.5)
axis.text.x = element_text(size = 10, colour = txtcol, angle = 0, hjust = 0.5),
legend.position = 'top'
)
p1 <- show_boxplot(epcdata, bay_segment = "OTB", yrrng = yrrng, yrsel = maxyr, partialyr = partialyr) + thrthm
p1leg <- g_legend(p1)
p1 <- p1 + theme(legend.position = 'none')
p2 <- show_boxplot(epcdata, bay_segment = "HB", yrrng = yrrng, yrsel = maxyr, partialyr = partialyr) + thrthm + theme(legend.position = 'none')
p3 <- show_boxplot(epcdata, bay_segment = "MTB", yrrng = yrrng, yrsel = maxyr, partialyr = partialyr) + thrthm + theme(legend.position = 'none')
p4 <- show_boxplot(epcdata, bay_segment = "LTB", yrrng = yrrng, yrsel = maxyr, partialyr = partialyr) + thrthm + theme(legend.position = 'none')
# align
# Get the widths
pA <- ggplot_gtable(ggplot_build(p1))
pB <- ggplot_gtable(ggplot_build(p2))
pC <- ggplot_gtable(ggplot_build(p3))
pD <- ggplot_gtable(ggplot_build(p4))
maxWidth = grid::unit.pmax(pA$widths[2:3], pB$widths[2:3], pD$widths[2:3], pD$widths[2:3])
# Set the widths
pA$widths[2:3] <- maxWidth
pB$widths[2:3] <- maxWidth
pC$widths[2:3] <- maxWidth
pD$widths[2:3] <- maxWidth
p1 <- show_boxplot(epcdata, bay_segment = "OTB", yrrng = yrrng, yrsel = maxyr, partialyr = partialyr)
p2 <- show_boxplot(epcdata, bay_segment = "HB", yrrng = yrrng, yrsel = maxyr, partialyr = partialyr)
p3 <- show_boxplot(epcdata, bay_segment = "MTB", yrrng = yrrng, yrsel = maxyr, partialyr = partialyr)
p4 <- show_boxplot(epcdata, bay_segment = "LTB", yrrng = yrrng, yrsel = maxyr, partialyr = partialyr)
p <- (guide_area() / (p1 + p2 + p3 + p4)) + plot_layout(ncol = 1, guides = 'collect', heights = unit(c(1, 1), c("cm", "null"))) & thrthm
pdf(here('figure', 'chlboxplot.pdf'), family = 'serif', height = 5.5, width = 8)
grid.arrange(
p1leg,
arrangeGrob(pA, pB, ncol = 2),
arrangeGrob(pC, pD, ncol = 2),
ncol = 1, heights = c(0.1, 1, 1)
)
p
dev.off()
@

Expand Down Expand Up @@ -196,7 +171,7 @@ dev.off()

\vspace{-0.1in}

\tiny \textit{\textbf{Note}: 2023 nutrient management compliance assessment available from Beck, M.W., Burke, M., Sherwood, E. 2024. TBEP Technical Report \#xx-24. Please cite this document as Beck, M.W., Burke, M., Sherwood, E. 2024. 2023 Tampa Bay Water Quality Assessment. TBEP Technical Report \#xx-23, St. Petersburg, FL.} \\
\tiny \textit{\textbf{Note}: 2023 nutrient management compliance assessment available from Beck, M.W., Burke, M., Sherwood, E. 2024. TBEP Technical Report \#xx-24. Please cite this document as Beck, M.W., Burke, M., Sherwood, E. 2024. 2023 Tampa Bay Water Quality Assessment. TBEP Technical Report \#xx-24, St. Petersburg, FL.} \\

\end{column}

Expand Down

0 comments on commit f79a265

Please sign in to comment.