Skip to content

Commit

Permalink
Expand y scale if all y values are equal
Browse files Browse the repository at this point in the history
  • Loading branch information
rich-iannone committed Dec 1, 2023
1 parent 03fe13a commit 8ff9e13
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions R/utils_plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ generate_nanoplot <- function(
y_scale_max <- get_extreme_value(y_vals, stat = "max")
y_scale_min <- get_extreme_value(y_vals, stat = "min")

if (y_scale_min == y_scale_max && is.null(expand_y)) {

# Expand the `y` scale, centering around the `y_scale_min` value
expand_y_dist <- (y_scale_min / 10) * 2
expand_y <- c(y_scale_min - expand_y_dist, y_scale_min + expand_y_dist)
}

# Ensure that a reference line or reference area isn't shown if NULL or
# any of its directives is NA
if (
Expand Down

0 comments on commit 8ff9e13

Please sign in to comment.