Reputation: 1011
I tried to set the legend position as a global option but it did not work. I was only able to set a theme as default, but not the legend position, as following:
theme_set(theme_bw()) # Defining the global theme
ggplot(data = iris, aes(x = Petal.Length, y=Sepal.Length, color = Species)) +
geom_point()
I want the legend position to be at the bottom of the plot (as it will work for every plot, i.e. globally). How can I do it?
Cheers
Upvotes: 1
Views: 2218
Reputation: 469
To change the default settings of ggplot2 you can do as follow:
new_theme <- theme_bw() %+replace%
theme(legend.position = "bottom")
theme_set(new_theme)
obs: you can do this for any arg.
Upvotes: 5
Reputation: 801
It should be sufficient to just add + theme(legend.position = 'bottom')
to your theme_set()
library(ggplot2)
theme_set(theme_bw() + theme(legend.position = 'bottom')) # Defining the global theme
ggplot(data = iris, aes(x = Petal.Length, y=Sepal.Length, color = Species)) +
geom_point()
Upvotes: 4