Skip to content

Instantly share code, notes, and snippets.

@baptiste
Created April 9, 2016 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baptiste/cc540f4ce6b6206978ee8789fc65cccc to your computer and use it in GitHub Desktop.
Save baptiste/cc540f4ce6b6206978ee8789fc65cccc to your computer and use it in GitHub Desktop.
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