copies across visual changes from inputs app to the rates funnel plot#78
copies across visual changes from inputs app to the rates funnel plot#78tomjemmett merged 1 commit intomainfrom
Conversation
tomjemmett
commented
Jan 22, 2026
- extend x-limits of the control lines to epand off edge of plot area (like centre line)
- adds more variables to control the colour/style of the control lines
- extend x-limits of the control lines to epand off edge of plot area (like centre line) - adds more variables to control the colour/style of the control lines
There was a problem hiding this comment.
Pull request overview
Updates the rates funnel plot styling/ranges to match visual behavior from the inputs app, specifically extending control-limit lines and making their styling more configurable in-code.
Changes:
- Adds separate line-type/colour variables for centre line, 2-sigma, and 3-sigma control lines.
- Extends the x-range for control-limit
geom_function()layers so they draw beyond the visible panel edge. - Sets an explicit x-range on the plot via
coord_cartesian(xlim = ...).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| cl3_colour <- "black" | ||
| cl_line_type <- "dashed" | ||
|
|
||
| plot_x_range <- c(0, max(rates_funnel_data$denominator) * 1.05) |
There was a problem hiding this comment.
plot_x_range/function_x_range start at 0. The control-limit functions produced by uprime_calculations() evaluate sqrt(cl / x) (see R/utils_plot.R:60), so sampling the function at x=0 yields Inf and can lead to warnings/incorrect rendering of the funnel control lines. Use a strictly positive lower bound for these x-limits (e.g., min_den <- min(rates_funnel_data$denominator[rates_funnel_data$denominator > 0]) or max(1, min_den)), and base the plot/function ranges off that instead of 0.
| plot_x_range <- c(0, max(rates_funnel_data$denominator) * 1.05) | |
| positive_denominators <- rates_funnel_data$denominator[rates_funnel_data$denominator > 0] | |
| min_den <- if (length(positive_denominators) && | |
| is.finite(min(positive_denominators, na.rm = TRUE))) { | |
| min(positive_denominators, na.rm = TRUE) | |
| } else { | |
| 1 | |
| } | |
| max_den <- max(rates_funnel_data$denominator, na.rm = TRUE) | |
| if (!is.finite(max_den)) { | |
| max_den <- min_den | |
| } | |
| plot_x_range <- c(min_den, max_den * 1.05) |
| cl_line_type <- "dashed" | ||
|
|
||
| plot_x_range <- c(0, max(rates_funnel_data$denominator) * 1.05) | ||
| function_x_range <- plot_x_range * 1.2 |
There was a problem hiding this comment.
function_x_range <- plot_x_range * 1.2 scales both the lower and upper bounds. If plot_x_range[1] is changed to a positive minimum (which is likely needed to avoid x=0 for the funnel functions), this will inadvertently increase the lower bound too. Prefer computing function_x_range by extending only the upper bound (keep the lower bound unchanged).
| function_x_range <- plot_x_range * 1.2 | |
| function_x_range <- c(plot_x_range[1], plot_x_range[2] * 1.2) |
matt-dray
left a comment
There was a problem hiding this comment.
Great, thanks for sticking this in.