From 0125724ea1dde391daa3fe08011daf7f4b28c835 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 3 Oct 2025 09:12:30 +0200 Subject: [PATCH 1/2] warn for infinite radius values --- R/geom-spoke.R | 4 ++++ tests/testthat/_snaps/geom-spoke.md | 4 ++++ tests/testthat/test-geom-spoke.R | 4 ++++ 3 files changed, 12 insertions(+) create mode 100644 tests/testthat/_snaps/geom-spoke.md create mode 100644 tests/testthat/test-geom-spoke.R diff --git a/R/geom-spoke.R b/R/geom-spoke.R index 71ac416482..e94448c697 100644 --- a/R/geom-spoke.R +++ b/R/geom-spoke.R @@ -8,6 +8,10 @@ GeomSpoke <- ggproto( data$radius <- data$radius %||% params$radius data$angle <- data$angle %||% params$angle + if (any(is.infinite(data$radius))) { + cli::cli_warn("Infinite {.field radius} values are unreliable.") + } + transform(data, xend = x + cos(angle) * radius, yend = y + sin(angle) * radius diff --git a/tests/testthat/_snaps/geom-spoke.md b/tests/testthat/_snaps/geom-spoke.md new file mode 100644 index 0000000000..e8d4aee5d9 --- /dev/null +++ b/tests/testthat/_snaps/geom-spoke.md @@ -0,0 +1,4 @@ +# geom_spoke warns about infinite radius (#6671) + + Infinite radius values are unreliable. + diff --git a/tests/testthat/test-geom-spoke.R b/tests/testthat/test-geom-spoke.R new file mode 100644 index 0000000000..0e189d9723 --- /dev/null +++ b/tests/testthat/test-geom-spoke.R @@ -0,0 +1,4 @@ +test_that("geom_spoke warns about infinite radius (#6671)", { + p <- ggplot() + geom_spoke(aes(0, 0, angle = pi / 4, radius = Inf)) + expect_snapshot_warning(ggplot_build(p)) +}) From 5a031d9964de1e94b16741025c8c1acc6e174e6e Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 3 Oct 2025 09:13:19 +0200 Subject: [PATCH 2/2] add news bullet --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 3e92547b2a..a696919ea4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,8 @@ ### Bug fixes +* Using infinite `radius` aesthetic in `geom_spoke()` now throws a warning + (#6671) * Fixed regression where `draw_key_rect()` stopped using `fill` colours (@mitchelloharawild, #6609). * Fixed regression where `scale_{x,y}_*()` threw an error when an expression