Youtube Channel: https://www.youtube.com/c/TechAnswers88
Video link https://youtu.be/iEfmwFIVLbQ
library(ggplot2)
library(ggeasy)
library(stringr)
df <- mpg
df
# This will capitalise the first character of the manufactuer name
df$manufacturer <- str_to_title(df$manufacturer)
df
pl <- ggplot(data = df,aes(x= manufacturer, fill = manufacturer))
pl <- pl + geom_bar()
pl <- pl + theme_classic()
pl <- pl + labs(title = "Barchart")
pl <- pl + labs(subtitle = "No of cars from each manufacturer")
pl <- pl + labs(caption = paste0("n=", nrow(df)))
pl <- pl + labs(x= "Manufacturer", y = "Cars")
pl
pl <- ggplot(data = df,aes(x= manufacturer, fill = manufacturer))
pl <- pl + geom_bar()
pl <- pl + theme_classic()
pl <- pl + labs(x= "Manufacturer", y = "Cars")
# Now add the ggeasy commands
pl <- pl + ggeasy::easy_all_text_color(color ="blue")
pl <- pl + ggeasy::easy_rotate_labels(which = "both", angle = 90)
#pl <- pl + ggeasy::easy_labs(title = "Barchart")
#pl <- pl + ggeasy::easy_labs(subtitle = "No of cars from each manufacturer")
#pl <- pl + ggeasy::easy_labs(caption = paste0("n=", nrow(df)))
pl <- pl + ggeasy::easy_add_legend_title("Manufacturers of Cars")
pl <- pl + ggeasy::easy_rotate_legend(to = c("horizontal"))
pl <- pl + ggeasy::easy_legend_at(to = c("bottom"))
pl <- pl + ggeasy::easy_adjust_legend("center")
pl <- pl + ggeasy::easy_all_text_size(size = 10)
pl <- pl + ggeasy::easy_remove_axes(which = c("both"), what ="tick")
pl