Skip to content

Commit

Permalink
- Added border to indicate if truncated.
Browse files Browse the repository at this point in the history
  • Loading branch information
joethorley committed Apr 22, 2024
1 parent 126af7b commit 3037770
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions R/gss-plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,26 @@ gss_plot <- function(
gss$ymin <- min(c(0, range[1]))
gss$ymax <- max(c(0, range[2]))

gss_start <- gss |>
dplyr::filter(!.data$truncation %in% c("both", "start"))

gss_end <- gss |>
dplyr::filter(!.data$truncation %in% c("both", "end"))

gp <- ggplot2::ggplot(data = data) +
ggplot2::facet_wrap(~.data$year, nrow = nrow, ncol = ncol) +
ggplot2::geom_hline(data = start_end_temperature, ggplot2::aes(yintercept = .data$temperature, linetype = .data$threshold),
color = "#E8613C") +
ggplot2::geom_rect(data = gss, ggplot2::aes(xmin = .data$start_dayte, xmax = .data$end_dayte, ymin = .data$ymin, ymax = .data$ymax),
alpha = 1/4) +
ggplot2::geom_segment(data = gss, ggplot2::aes(x = .data$start_dayte, xend = .data$end_dayte, y = .data$ymin),
alpha = 1/2) +
ggplot2::geom_segment(data = gss, ggplot2::aes(x = .data$start_dayte, xend = .data$end_dayte, y = .data$ymax),
alpha = 1/2) +
ggplot2::geom_segment(data = gss_start, ggplot2::aes(y = .data$ymin, yend = .data$ymax, x = .data$start_dayte),
alpha = 1/2) +
ggplot2::geom_segment(data = gss_end, ggplot2::aes(y = .data$ymin, yend = .data$ymax, x = .data$end_dayte),
alpha = 1/2) +
ggplot2::geom_line(ggplot2::aes(x = .data$dayte, y = .data$temperature, group = .data$series, color = .data$series)) +
ggplot2::scale_x_date("Date", date_labels = "%b", date_breaks = "month") +
ggplot2::scale_y_continuous("Water Temperature (C)") +
Expand Down
Binary file modified tests/testthat/_snaps/gss-plot/gss_plot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testthat/_snaps/gss-plot/gss_plot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testthat/_snaps/gss-plot/gss_plot4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testthat/_snaps/gss-plot/gss_plot5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testthat/_snaps/gss-plot/gss_plot6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3037770

Please sign in to comment.