Home > Net >  How do I change the order of the y-axis in ggplot2 R?
How do I change the order of the y-axis in ggplot2 R?

Time:05-02

I am trying to make a geom_density_ridges_gradient() graph in R, and want to order the y-axis in chronological order of release (a separate variable in my dataframe). How can I edit my ggplot() command to make this happen? Here is what I currently have, and attached is the output. Or, for simplicity sake, how can I manually order the y-axis categories?

ggplot(ts, aes(x = danceability, y = album_name))  
  geom_density_ridges_gradient(scale = .9)  
  theme_light()  
  labs(title = "Danceability by Albums",
       x = "Danceability",
       y = "Album Name")

yorder_plot

  • Related