I need to make a width red quarter circle using ggplot2.
My best attempt was using ggforce:geom_arc2() but it is not perfect.
- It is not the same width for the whole arc. Strange.
- I would rather use pure ggplot2()
Here are my code:
library(ggforce)
library(ggplot2)
l1 <- data.frame(x = c(0,50), y = c(30,30))
l2 <- data.frame(x = c(0,50), y = c(50,50))
l3 <- data.frame(x = c(30,30), y = c(0,50))
l4 <- data.frame(x = c(50,50), y = c(0,50))
a1 <- data.frame(x0 = 0, y0 = 0, r0 = 0, r = 40, angle = c(0, pi/2))
g <- ggplot()
g <- g + geom_arc2(data = a1, size = 80, color = "red",
aes(x0 = 0, y0 = 0, r = r, end = angle))
g <- g + geom_path(data = l1, aes(x,y))
g <- g + geom_path(data = l2, aes(x,y))
g <- g + geom_path(data = l3, aes(x,y))
g <- g + geom_path(data = l4, aes(x,y))
g <- g + coord_cartesian(expand = FALSE, xlim = c(-5, 55), ylim = c(-5, 55))
g