library(grid)
grid.newpage()
p1 <- pieGrob(x = 0.2, y = 0.2,
values = c(.7, .1, .1, .1), radius = 1,
fill = c("purple", "red", "green", "orange"))
grid.draw(p1)
## Change unit of radius using `radius_unit` and slice colours using `fill`
## Note `values` don't need to proportions. They can be anything and
## proportions would be calculated
grid.newpage()
p2 <- pieGrob(x = 0.5, y = 0.75,
values = c(1, 2, 3, 4, 5), radius = 1,
radius_unit = "in",
fill = c("purple", "yellow", "green", "orange", "blue"))
grid.draw(p2)
## Change border attributes using `col`, `lwd`, and `lty`
grid.newpage()
p3 <- pieGrob(x = 0.5, y= 0.5,
values = c(10, 40, 50), radius = 20,
radius_unit = "mm",
col = "red", lwd = 5, lty = 3,
fill = c("purple", "yellow", "blue"))
grid.draw(p3)
## Use `alpha` to change opacity of pies
grid.newpage()
p4 <- pieGrob(x = 0.25, y = 0.75,
values = c(50), radius = 25,
radius_unit = "mm", edges = 36000,
col = "navy", lwd = 4, lty = "33",
fill = c("purple4"), alpha = 0.5)
grid.draw(p4)
## Use `edges` to increase resolutino of pie-charts
grid.newpage()
p5 <- pieGrob(x = 0.8, y = 0.2,
values = c(.7, .1, .1, .1), radius = 1,
fill = c("purple", "red", "green", "orange"),
edges = 10000)
grid.draw(p5)
Run the code above in your browser using DataLab