Load packages library(tidyverse) library(forcats) library(hrbrthemes) What we want to achieve: barplot ggplot2-diagram where bars and legend labels are sorted Say we would like to plot frequencies, and would like to use ggplot2 for that purpose. How can we get a decent graph? This post shows some ways. Some data data(diamonds) A glimpse to the data glimpse(diamonds) #> Rows: 53,940 #> Columns: 10 #> $ carat <dbl> …