Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. library(ggplot2)
  2.  
  3. blank_theme <- theme_minimal()+
  4. theme(
  5. axis.title.x = element_blank(),
  6. axis.title.y = element_blank(),
  7. panel.border = element_blank(),
  8. panel.grid=element_blank(),
  9. axis.ticks = element_blank(),
  10. plot.title=element_text(size=14, face="bold")
  11. )
  12.  
  13.  
  14.  
  15. dat = data.frame(count=c(319, 442, 239), category=c("University", "High Scool", "Lower"))
  16.  
  17.  
  18. dat$fraction = dat$count / sum(dat$count)
  19.  
  20. dat$ymax = cumsum(dat$fraction)
  21. dat$ymin = c(0, head(dat$ymax, n=-1))
  22.  
  23. dat$category <- factor(dat$category, levels = c("University", "High Scool", "Lower"))
  24.  
  25.  
  26. p1 = ggplot(dat, aes(fill=category, ymax=ymax, ymin=ymin, xmax=4, xmin=3)) +
  27. geom_rect(color='blue') +
  28. coord_polar(theta="y") +
  29. xlim(c(1, 4))
  30.  
  31.  
  32.  
  33. edu<-p1 + scale_fill_brewer("Education") + blank_theme +
  34. theme(axis.text.x=element_blank()) + theme(legend.position=c(.5, .5)) + ggtitle("") +
  35. theme(panel.grid=element_blank()) +
  36. theme(axis.text=element_blank()) +
  37. theme(axis.ticks=element_blank()) +
  38. theme(legend.title = element_text(size=16, face="bold")) +
  39. theme(legend.text = element_text(size = 14, face = "bold"))
  40.  
  41. edu
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement