我尝试将图例位置设置为全局选项,但它不起作用。我只能将主题设置为默认,但不能将图例位置设置为默认,如下所示:
theme_set(theme_bw()) # Defining the global theme
ggplot(data = iris, aes(x = Petal.Length, y=Sepal.Length, color = Species)) +
geom_point()
Run Code Online (Sandbox Code Playgroud)
我希望图例位置位于图的底部(因为它适用于每个图,即全局)。我该怎么做?
干杯
小智 5
要更改 ggplot2 的默认设置,您可以执行以下操作:
new_theme <- theme_bw() %+replace%
theme(legend.position = "bottom")
theme_set(new_theme)
Run Code Online (Sandbox Code Playgroud)
obs:您可以对任何参数执行此操作。