Skip to content

Commit

Permalink
refac: simplify the logic and code in plot_seroprev
Browse files Browse the repository at this point in the history
  • Loading branch information
ntorresd committed Mar 5, 2024
1 parent 0b32362 commit 05ad912
Showing 1 changed file with 21 additions and 29 deletions.
50 changes: 21 additions & 29 deletions R/visualisation.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,40 +32,32 @@ plot_seroprev <- function(serodata,
}

if (bin_data) {
serodata_bin <- prepare_bin_data(
serodata <- prepare_bin_data(
serodata,
bin_step = bin_step
)
min_prev <- min(serodata_bin$prev_obs_lower)
max_prev <- max(serodata_bin$prev_obs_upper)
}

seroprev_plot <- ggplot2::ggplot(
data = serodata_bin,
ggplot2::aes(x = .data$age_mean_f)
)
} else {
min_prev <- min(serodata$prev_obs_lower)
max_prev <- max(serodata$prev_obs_upper)

seroprev_plot <- ggplot2::ggplot(
data = serodata,
ggplot2::aes(x = .data$age_mean_f)
)
}
seroprev_plot <- seroprev_plot +
ggplot2::geom_errorbar(
ggplot2::aes(
ymin = .data$prev_obs_lower,
ymax = .data$prev_obs_upper
),
width = 0.1
min_prev <- min(serodata$prev_obs_lower)
max_prev <- max(serodata$prev_obs_upper)

seroprev_plot <- ggplot2::ggplot(
data = serodata,
ggplot2::aes(x = .data$age_mean_f)
) +
ggplot2::geom_point(
ggplot2::aes(
y = .data$prev_obs,
size = .data$total
),
fill = "#7a0177", colour = "black", shape = 21
ggplot2::geom_errorbar(
ggplot2::aes(
ymin = .data$prev_obs_lower,
ymax = .data$prev_obs_upper
),
width = 0.1
) +
ggplot2::geom_point(
ggplot2::aes(
y = .data$prev_obs,
size = .data$total
),
fill = "#7a0177", colour = "black", shape = 21
) +
ggplot2::coord_cartesian(
xlim = c(min(serodata$age_min), max(serodata$age_max)),
Expand Down

0 comments on commit 05ad912

Please sign in to comment.