Skip to content

copies across visual changes from inputs app to the rates funnel plot#78

Merged
tomjemmett merged 1 commit intomainfrom
funnel-plot-changes
Jan 26, 2026
Merged

copies across visual changes from inputs app to the rates funnel plot#78
tomjemmett merged 1 commit intomainfrom
funnel-plot-changes

Conversation

@tomjemmett
Copy link
Member

  • 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
Copilot AI review requested due to automatic review settings January 22, 2026 21:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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)

Copilot uses AI. Check for mistakes.
cl_line_type <- "dashed"

plot_x_range <- c(0, max(rates_funnel_data$denominator) * 1.05)
function_x_range <- plot_x_range * 1.2
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
function_x_range <- plot_x_range * 1.2
function_x_range <- c(plot_x_range[1], plot_x_range[2] * 1.2)

Copilot uses AI. Check for mistakes.
@matt-dray matt-dray removed the request for review from DCEW January 23, 2026 12:33
@matt-dray matt-dray added this to the v0.3.3 milestone Jan 23, 2026
Copy link
Contributor

@matt-dray matt-dray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks for sticking this in.

@tomjemmett tomjemmett merged commit 4e24195 into main Jan 26, 2026
8 checks passed
@tomjemmett tomjemmett deleted the funnel-plot-changes branch January 26, 2026 09:57
@matt-dray matt-dray added the enhancement New feature or request label Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants