Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

geom_arc2() size parameter #237

Closed
MartinMSPedersen opened this issue Apr 2, 2021 · 1 comment
Closed

geom_arc2() size parameter #237

MartinMSPedersen opened this issue Apr 2, 2021 · 1 comment

Comments

@MartinMSPedersen
Copy link

I am trying to make a large red quarter circle using the code below.
I want the circle to have a width of 20.

  1. Does the size parameter work correctly? Is size and width the same?
  2. I expects the width same for the whole arc. It looks like it is wider to the left than to the bottom.
    geom_arc2
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
@thomasp85
Copy link
Owner

size (now linewidth) is the width of the line and is an absolute value not related to the coordinate system. if you want to control the width in relation to the coordinate system you can use geom_arc_bar()

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 = 30, r = 50, angle = c(0, pi/2))

g <- ggplot()
g <- g + geom_arc_bar(data = a1, fill = "red", colour = NA,
                   aes(x0 = 0, y0 = 0, r0 = r0, r = r, start = 0, 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants