Created
April 9, 2016 02:39
-
-
Save baptiste/cc540f4ce6b6206978ee8789fc65cccc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(grid) | |
lollipopGrob <- function(x, y, size, turns=3){ | |
theta <- seq(0, turns*2*pi, length=120) | |
xx <- unit(x, "npc") + unit(size*theta/max(theta)*cos(theta+pi), "mm") | |
yy <- unit(y, "npc") + unit(size*theta/max(theta)*sin(theta+pi), "mm") | |
segmentsGrob(head(xx, -1), head(yy, -1), tail(xx, -1), tail(yy, -1), | |
gp=gpar(col=hcl(seq(0,360,length=12), 90, 70), lwd=5)) | |
} | |
l <- lollipopGrob(0.5, 0.5, 5) | |
grid.newpage() | |
grid.segments(0, 0.5, 0.5, 0.5) | |
grid.draw(l) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment