Skip to content

Commit 5326a21

Browse files
authored
Warn about infinite geom_spoke(radius) (#6678)
* warn for infinite radius values * add news bullet
1 parent 3d88c7a commit 5326a21

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# ggplot2 (development version)
22

3+
* Using infinite `radius` aesthetic in `geom_spoke()` now throws a warning
4+
(#6671)
35
* Scales and guides specified by a string can now use package name prefixes to
46
indicate a namespace wherein to look for the scale/guide. For example, one can
57
use `scale_x_continuous(guide = "legendry::axis_base")` (@teunbrand, #4705).

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)