-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Labels
layers 📈messagesrequests for improvements to error, warning, or feedback messagesrequests for improvements to error, warning, or feedback messages
Description
Simple segment at a 45° angle:
library(ggplot2)
ggplot() +
geom_spoke(
data = data.frame(angle = pi / 4, radius = 10),
aes(0, 0, angle = angle, radius = radius),
) +
annotate("point", x = 2, y = 2)
The angle is correct (passes through the x = y point)
I can use radius = Inf
to extend it to the limits of the plots and still works.
ggplot() +
geom_spoke(
data = data.frame(angle = pi / 4, radius = Inf),
aes(0, 0, angle = angle, radius = radius),
) +
annotate("point", x = 2, y = 2)
However, when there is other data, infinite radius is draw with the wrong angle
data.frame(x = rnorm(100, sd = 2)) |>
transform(y = x^2 + rnorm(100)) |>
ggplot(aes(x, y)) +
geom_point() +
geom_spoke(
data = data.frame(angle = pi / 4, radius = Inf),
aes(0, 0, angle = angle, radius = radius),
) +
geom_spoke(
data = data.frame(angle = pi / 4, radius = 10),
color = "red",
aes(0, 0, angle = angle, radius = radius),
) +
annotate("point", x = 10, y = 10, color = "red")
It seems to be pointing to the upper right corner of the plot
data.frame(x = rnorm(100, sd = 2)) |>
transform(y = x^2 + rnorm(100)) |>
ggplot(aes(x, y)) +
geom_point() +
geom_spoke(
data = data.frame(angle = pi / 4, radius = Inf),
aes(0, 0, angle = angle, radius = radius),
) +
geom_spoke(
data = data.frame(angle = pi / 4, radius = 10),
color = "red",
aes(0, 0, angle = angle, radius = radius),
) +
annotate("point", x = 10, y = 10, color = "red") +
lims(y = c(NA, 30))
Metadata
Metadata
Assignees
Labels
layers 📈messagesrequests for improvements to error, warning, or feedback messagesrequests for improvements to error, warning, or feedback messages