Home > database >  position legend "bottom" in theme_bw() or theme_classic()
position legend "bottom" in theme_bw() or theme_classic()

Time:03-03

I want to plot something without using theme(), but instead theme_classic(). How can I change the position of the legend to the "bottom"?

Thanks!

CodePudding user response:

I also struggled to answer your question; @JonSpring provided valuable code and explanation.

Sample code:

ggplot(diamonds, mapping = aes(x = clarity))   
  geom_bar(aes(fill = cut))   
  labs(x = NULL, y = NULL)   
  guides(x = "none", y = "none") 
  theme_classic() 
   theme(legend.position = 'bottom', legend.direction = "horizontal")

Output:

enter image description here

  • Related