diff --git a/R/logistic_ex.R b/R/logistic_ex.R index eaebbc1..1b4a37c 100644 --- a/R/logistic_ex.R +++ b/R/logistic_ex.R @@ -31,7 +31,7 @@ toplo <- toprd |> prd = prds$fit, hival = prds$fit + 1.96 * prds$se.fit, loval = prds$fit - 1.96 * prds$se.fit, - Turbidity = factor( Turbidity, labels = c('95th %tile','mean'), levels = unique(Turbidity) ) + Turbidity = factor( Turbidity, labels = c('Elevated','Normal'), levels = unique(Turbidity) ) ) # get lines to show connection between hypothetical target and certainty of meeting threshold @@ -45,24 +45,28 @@ tolns <- trgs |> prd = lnprds$fit, hival = lnprds$fit + 1.96 * lnprds$se.fit, loval = lnprds$fit - 1.96 * lnprds$se.fit, - Turbidity = factor( Turbidity, labels = c('95th %tile','mean'), levels = unique(Turbidity) ) + Turbidity = factor( Turbidity, labels = c('Elevated','Normal'), levels = unique(Turbidity) ) ) # plot -p <- ggplot(toplo, aes(x = value, y = prd, fill = Turbidity, color = Turbidity, group = Turbidity)) + - geom_ribbon(aes(ymin = loval, ymax = hival), alpha = 0.2) + - geom_line() + - geom_segment(data = tolns, aes(x = value, xend = value, y = 0, yend = hival), linetype = 'dashed', inherit.aes = F) + - geom_segment(data = tolns, aes(x = 0, xend = value, y = loval, yend = loval), linetype = 'dashed') + - geom_segment(data = tolns, aes(x = 0, xend = value, y = hival, yend = hival), linetype = 'dashed') + +p <- ggplot(toplo, aes(x = value, y = prd, group = Turbidity)) + + geom_ribbon(aes(ymin = loval, ymax = hival, fill = Turbidity), alpha = 0.2) + + geom_line(aes(color = Turbidity)) + + geom_segment(data = tolns, aes(color = Turbidity, x = value, xend = value, y = 0, yend = prd), linetype = 'dashed', inherit.aes = F) + + geom_segment(data = tolns, aes(color = Turbidity, x = 0, xend = value, y = prd, yend = prd), linetype = 'dashed') + + # geom_segment(data = tolns, aes(x = 0, xend = value, y = hival, yend = hival), linetype = 'dashed') + + scale_color_manual(values = c('tomato1', 'dodgerblue')) + + scale_fill_manual(values = c('tomato1', 'dodgerblue')) + + coord_cartesian(xlim = c(0, 200)) + theme_minimal() + theme(legend.position = 'top') + labs( - x = 'Monthly TN load', - y = 'Probability of attaining 9.3 µg/L', - caption = 'Hypothetical example of how to use model to set TN load targets' - ) + x = 'Monthly nitrogen load', + fill = 'Climate condition', + color = 'Climate condition', + y = 'Probability of meeting water quality goal' + ) -png(here::here('figs/logisticex.png'), width = 6, height = 4, units = 'in', res = 300) +png(here::here('figs/logisticex.png'), width = 5, height = 4, units = 'in', res = 300) print(p) dev.off() diff --git a/figs/logisticex.png b/figs/logisticex.png index 863c276..429678c 100644 Binary files a/figs/logisticex.png and b/figs/logisticex.png differ