Skip to content

Commit

Permalink
🐛 Fix rescaling issue (#68)
Browse files Browse the repository at this point in the history
* delay guide rescaling

* add news bullet
  • Loading branch information
teunbrand authored Mar 4, 2025
1 parent ff7ebec commit 92c50c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
`key_sequence()` and binned scales invoke `key_bins()`.
* When using a binned key in `gizmo_histogram()`, the default `hist(breaks)`
argument is populated with the key's breaks.
* Fix capping issue with non-canonical rescalers in `primitive_line()` (#67)

# legendry 0.2.0

Expand Down
11 changes: 4 additions & 7 deletions R/primitive-line.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,7 @@ PrimitiveLine <- ggproto(
decor[[opposite]] <- value
} else {
value <- scale$oob(decor[[aesthetic]], range = limits)
if (is_theta(position)) {
decor[[aesthetic]] <- value
} else {
decor[[aesthetic]] <- scale$rescale(value, limits)
}
decor[[aesthetic]] <- value
}

group <- seq_len(ceiling(nrow(decor) / 2))
Expand Down Expand Up @@ -138,12 +134,13 @@ PrimitiveLine <- ggproto(
y <- unit(decor$y, "npc") + unit(cos(theta) * offset, "cm")
}
if (!all(c("x", "y") %in% names(decor))) {
value <- guide_rescale(decor[[params$aesthetic]], params$limits)
if (params$position %in% c("left", "right")) {
y <- unit(decor[[params$aesthetic]], "npc")
y <- unit(value, "npc")
x <- as.numeric(params$position == "left") |>
rep(length.out = length(y)) |> unit("npc")
} else {
x <- unit(decor[[params$aesthetic]], "npc")
x <- unit(value, "npc")
y <- as.numeric(params$position == "bottom") |>
rep(length.out = length(x)) |> unit("npc")
}
Expand Down

0 comments on commit 92c50c9

Please sign in to comment.