I am wondering why guides change the order inside legend (ie color then shape)?
library(ggplot2)
basic <- ggplot(mtcars, aes(wt, mpg, colour = factor(cyl), shape = factor(vs) )) +
geom_point()
basic
basic + labs(color = "color")
basic + guides(color = guide_legend(title = "color"), shape = guide_legend(title = "shape"))
Hello @melgoussi ! I'm not sure why the order changes, but you can specify the order of multiple legends using the order argument within guide_legend()
.
basic + guides(color = guide_legend(title = "color"),
shape = guide_legend(title = "shape"))
basic + guides(color = guide_legend(title = "color", order = 2),
shape = guide_legend(title = "shape", order = 1))
Created on 2023-06-13 with reprex v2.0.2
1 Like
system
Closed
July 4, 2023, 8:59pm
3
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.