mtcars
数据为例,我尝试将图例放在bottom
。在第一张图表中不使用theme_bw()
即可正常工作。添加theme_bw()
后,图例将向右移动。我做错了什么,如何解决?谢谢。 library(tidyverse)
mtcars %>%
ggplot(aes(x = factor(cyl), y = mpg,
color = factor(am)
)
) +
geom_boxplot() +
facet_wrap(vars(vs)) +
theme(legend.position = "bottom",
legend.title = element_blank())
mtcars %>%
ggplot(aes(x = factor(cyl), y = mpg,
color = factor(am))) +
geom_boxplot() +
facet_wrap(vars(vs)) +
theme(legend.position = "bottom",
legend.title = element_blank()) +
theme_bw()
由reprex package(v0.3.0)在2020-02-20创建
在下面的代码和图形中,以mtcars数据为例,我尝试将图例放在底部。无需在第一个图中使用theme_bw()即可正常工作。一旦添加theme_bw(),图例将移至...theme
和theme_bw
的顺序,因为如果theme_bw
位于结尾,则theme
会覆盖theme_bw
中的设置。