ggplot2 Bar Chart - Simple to Powerful Themes with Kaggle Notebook

In this R tutorial, We’ll learn the following tips and tricks of ggplot2 bar chart

  • Create a new R Notebook from Kaggle Dataset
  • Clean Column names with Janitor
  • How Make a Ggplot2 Bar Chart (Column Chart) in R
  • Why use geom_col instead of geom_bar
  • How to flip the coordinates of ggplot Bar charts
  • How to reorder the Bars in Ggplot Bar Chart
  • How to add Labels to a ggplot bar chart
  • How to make a beautiful ggplot2 bar chart from Basic to Powerful Themes using ggthemes

Video Tutorial on ggplot2 Bar Chart Themes

Final Code - Economist Theme

state_2018 %>%
    select(one_of('state_ut','total_victims')) %>%
    arrange(desc(total_victims)) %>%
    head(20) %>%
    mutate(state_ut = fct_reorder(state_ut,total_victims)) %>%
    ggplot() + geom_col(aes(y = state_ut,x =total_victims), fill = 'red') +
    geom_label(aes(y = state_ut,x =total_victims, label = total_victims), fill = 'yellow')+
    labs(title = '2018 Rape Victims in India - Top 20 states',
        subtitle = 'by Total Victim Count',
        caption = 'Data Source: Kaggle / Crimes in India') +
#theme_hc(style = 'darkunica') +
theme_economist() +
theme(axis.text.x = element_text(color = 'red'),
     axis.text.y = element_text(color = 'red'))

Kaggle Notebook - Complete Code

Crime in India - ggplot2 Bar Chart Evolution

comments powered by Disqus