0
guides(color = guide_legend(ncol=2, 
                            override.aes = list(size=c(1,0.05,0.05,1,0.05,0.05),
                            color = c("red", "red", "red", "blue", "blue", "blue"),
                            linetype = c("solid", "dashed", "dashed", 
                                         "solid", "dashed", "dashed")))) +
labs(x = "vote round", y = "RT(Millisecond)") +

It seems that override.aes = list(size=c(1,0.05,0.05,1,0.05,0.05) can not work out?

Z.Lin
  • 28,055
  • 6
  • 54
  • 94
高敬媛
  • 1
  • 1
  • It sounds like your actual use case involves multiple aesthetic mappings (colour, linetype, & size), for which you want a combined legend. If this is the case, showing your actual code / data (or a similar sample) with a [reproducible example](https://stackoverflow.com/q/5963269/8449629) will likely get you more targeted help. – Z.Lin Apr 02 '23 at 03:43

1 Answers1

0

We could adjust the size of the legend by using theme(legend.key.size = unit(1.5, "cm")), here is an example:

library(ggplot2)

ggplot(mtcars, aes(x=cyl, y=mpg, color = factor(am))) +
  geom_point() +
  labs(color = "My Legend") +
  theme(legend.key.size = unit(1.5, "cm"))

enter image description here

TarJae
  • 72,363
  • 6
  • 19
  • 66