Skip to content

Commit

Permalink
Merge branch 'master' into variable_pointsize
Browse files Browse the repository at this point in the history
  • Loading branch information
slowkow authored Jan 22, 2024
2 parents 496fdd9 + 1144585 commit 16e3493
Show file tree
Hide file tree
Showing 2 changed files with 14 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 = "kslowikowski@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-2843-6370")),
person("Pedro", "Aphalo", role = "ctb", comment = c(ORCID = "0000-0003-3385-972X")),
Expand Down
21 changes: 13 additions & 8 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,25 @@ 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])
}

# Utilities for converting units to centimetres
x_cm <- function(x) convertX(x, "cm", valueOnly = TRUE)
y_cm <- function(x) convertY(x, "cm", valueOnly = TRUE)
Expand All @@ -104,6 +108,7 @@ height_cm <- function(x) convertHeight(x, "cm", valueOnly = TRUE)
length_cm <- function(x) {
convertUnit(x, "cm", typeFrom = "dimension", valueOnly = TRUE)
}

# Need to set a viewport with the correct graphical parameters to correctly
# convert the size to centimetres
string_cm <- function(x, gp) {
Expand Down

0 comments on commit 16e3493

Please sign in to comment.