R/sphsu_show_colours.R

Defines functions sphsu_show_colours

Documented in sphsu_show_colours

#' See colours and colour names
#'
#' Displays all colours in a pie chart
#' @return A pie chart ggplot graph object
#' @export
#' @examples
#' sphsu_show_colours()

sphsu_show_colours <-
function() {
  Colour <- hjust <- vals <- NULL
df <- data.frame(Colour = factor(sphsu_cols(), levels = sphsu_cols()),
       names = names(sphsu_cols()),
       vals = 1,
       hjust = c(rep(0.5,12), 0.3))

  ggplot(df, aes(x = 1, y= vals, fill = Colour, label = names)) +
  geom_bar(stat = "identity", position = "fill") +
  coord_polar(theta = "y") +
  theme(text = element_blank(),
        rect = element_blank(),
        line = element_blank(),
        legend.position = "none") +
  scale_fill_identity(aesthetics = c("fill","colour")) +
  geom_text(aes(x=1.7, col=Colour, hjust = hjust ,y = 1/13),
            position=position_fill(vjust=0.5), fontface = "bold", family = "sans")
}
andrewbaxter439/SPHSUgraphs documentation built on Nov. 4, 2023, 11:52 p.m.