I'm trying to get a plot with two legends, one at the bottom and the other at the right side of the plot.
library(tidyverse)
df <- tibble(names = mtcars %>%
rownames(),
mtcars)
#plot 1
p1 <- df %>%
filter(names == "Duster 360" | names == "Valiant") %>%
ggplot(aes(x = as.factor(cyl), y = mpg, color = names)) +
geom_point() +
geom_hline(aes(yintercept = 20, linetype = "a")) +
theme(legend.position = "bottom")
p1
Desired plot (legend should be outside of plot):
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…