Skip to content

Commit

Permalink
change how we handle Inf
Browse files Browse the repository at this point in the history
This should fix issue #252
  • Loading branch information
slowkow committed Jan 22, 2024
1 parent cb2de65 commit 1144585
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: ggrepel
Version: 0.9.5
Version: 0.9.5.9999
Authors@R: c(
person("Kamil", "Slowikowski", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-2843-6370")),
person("Alicia", "Schep", role = "ctb", comment = c(ORCID = "0000-0002-3915-0618")),
Expand Down
20 changes: 12 additions & 8 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,21 @@ parse_safe <- function(text) {
#' @noRd
exclude_outside <- function(data, panel_scales) {
if ("x.range" %in% names(panel_scales)) {
ix <- data$x >= panel_scales$x.range[1] &
data$x <= panel_scales$x.range[2] &
data$y >= panel_scales$y.range[1] &
data$y <= panel_scales$y.range[2]
xr <- panel_scales$x.range
yr <- panel_scales$y.range
ix <- inside(data$x, xr) & inside(data$y, yr)
data <- data[ix,,drop=FALSE]
} else if ("x_range" %in% names(panel_scales)) {
ix <- data$x >= panel_scales$x_range[1] &
data$x <= panel_scales$x_range[2] &
data$y >= panel_scales$y_range[1] &
data$y <= panel_scales$y_range[2]
xr <- panel_scales$x_range
yr <- panel_scales$y_range
ix <- inside(data$x, xr) & inside(data$y, yr)
data <- data[ix,,drop=FALSE]
}
data
}

#' Exclude data points outside the panel ranges
#' @noRd
inside <- function(x, bounds) {
is.infinite(x) | (x <= bounds[2] & x >= bounds[1])
}

0 comments on commit 1144585

Please sign in to comment.