0

my original code

SubCategory=chr; Sales=dbl

ggplot(superstore) + 
  geom_col(mapping = aes(x = SubCategory, y = Sales, fill = SubCategory)) +
  theme(axis.text.x = element_text(angle = 90))

orders the columns alphabetically graph 1

my attempt to fix it

ggplot(superstore) + 
  geom_col(mapping = aes(x = fct_reorder(SubCategory, -Sales), 
                         y = Sales, fill = SubCategory)) + 
  theme(axis.text.x = element_text(angle = 90))

graph 2

Created some new strange order that is neither value nor alphabetical.

Am I using the wrong Geom?

0 Answers0