Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. #Themes
  2.  
  3. #Checking the theme options
  4. ?theme
  5.  
  6. #We can set a theme as the default, for example
  7. theme_set(theme_bw())
  8.  
  9. #Defining the general colors to avoid hard coding
  10. fill_color = 'white'
  11. decoration_color = '#778287'
  12. main1_color = '#478adb'
  13. main2_color = '#f206d3'
  14.  
  15. #Creare a theme we can apply everywhere
  16. sandra_theme<-theme_bw() + theme(
  17. panel.grid.major = element_blank(),
  18. panel.grid.minor = element_blank(),
  19. plot.title = element_text(size = 14, hjust = 0.2, color = decoration_color),
  20. axis.title = element_text(size = 10, hjust = 0.5, color = decoration_color),
  21. axis.text = element_text(colour = decoration_color, size = 8),
  22. axis.ticks = element_blank(),
  23. axis.line = element_line(colour = decoration_color, size=0.3, linetype = "dashed"),
  24. panel.border = element_blank(),
  25. panel.grid = element_blank(),
  26. strip.text = element_text(size = 12, color = decoration_color),
  27. panel.background = element_blank(),
  28. strip.background =element_blank(),
  29. plot.background = element_blank(),
  30. legend.position="None"
  31. )
  32.  
  33. #Now we set the new defined theme to the default option
  34. theme_set(sandra_theme)
  35.  
  36. #Creare a theme that includes a legend
  37. sandra_theme2<-theme_bw() + theme(
  38. panel.grid.major = element_blank(),
  39. panel.grid.minor = element_blank(),
  40. plot.title = element_text(size = 14, hjust = 0.2, color = decoration_color),
  41. axis.title = element_text(size = 10, hjust = 0.5, color = decoration_color),
  42. axis.text = element_text(colour = decoration_color, size = 8),
  43. axis.ticks = element_blank(),
  44. axis.line = element_line(colour = decoration_color, size=0.3, linetype = "dashed"),
  45. panel.border = element_blank(),
  46. panel.grid = element_blank(),
  47. strip.text = element_text(size = 12, color = decoration_color),
  48. panel.background = element_blank(),
  49. strip.background =element_blank(),
  50. plot.background = element_blank(),
  51. legend.text = element_text(size = 10, hjust = 0.5, color = decoration_color),
  52. legend.position = c(0.815, 0.27),
  53. legend.key = element_blank(),
  54. legend.title = element_blank()
  55. )
  56.  
  57. #Now we set the new defined theme to the default option
  58. theme_set(sandra_theme2)
  59.  
  60. #There is also a dark theme option with black background
  61. theme_set(dark_theme_gray())
  62.  
  63. #Excercise: choose a different dataset and create a basic chart.
  64. #Then build your own personalised a theme and apply it to the chart.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement