My question is an extension of this question. Note that I'm using version 2.3.0 which is available on github, not yet on CRAN.
library(ggplot2)
df <- data.frame("Categories" = rep(c("A", "B", "C"), 3),
"values" = c(rep(0.39, 3), rep(0.37, 3), rep(0.24, 3)),
"X" = 1:9)
ggplot(df, aes(x = X, y = values, colour = Categories)) +
geom_line() +
theme(
legend.position = "top",
legend.spacing.x = unit(2, unit = "cm"),
legend.title = element_blank()
)
The code above creates this plot.
I would like to move the legend labels (A, B, C) closer to their corresponding icons, as shown by the red arrows below, which would create more whitespace between the legend categories. How would I do that?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…