在以下使用
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()
本文创建于2020年2月20日,使用reprex包 (v0.3.0)