Skip to content

Commit 0125724

Browse files
committed
warn for infinite radius values
1 parent 6a447ba commit 0125724

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

R/geom-spoke.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ GeomSpoke <- ggproto(
88
data$radius <- data$radius %||% params$radius
99
data$angle <- data$angle %||% params$angle
1010

11+
if (any(is.infinite(data$radius))) {
12+
cli::cli_warn("Infinite {.field radius} values are unreliable.")
13+
}
14+
1115
transform(data,
1216
xend = x + cos(angle) * radius,
1317
yend = y + sin(angle) * radius
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# geom_spoke warns about infinite radius (#6671)
2+
3+
Infinite radius values are unreliable.
4+

tests/testthat/test-geom-spoke.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
test_that("geom_spoke warns about infinite radius (#6671)", {
2+
p <- ggplot() + geom_spoke(aes(0, 0, angle = pi / 4, radius = Inf))
3+
expect_snapshot_warning(ggplot_build(p))
4+
})

0 commit comments

Comments
 (0)