Hi Radha,
You can change the order of legends in any order using the order attribute within the function of the guide.
Suppose my legends are as below -
ggplot(mpg, aes(displ, hwy, col = cyl)) + geom_point(size = 2,aes(shape = factor(cyl))) + theme(legend.box.margin = margin(0.3,0.3,0.3,0.3,"cm"),legend.background = element_rect(color = "yellow")) + guides(shape = guide_legend(title = "cyl")) + scale_shape_discrete(labels = c("a","b","c","d")) + theme(legend.position = "bottom")
I change the order using code below -
ggplot(mpg, aes(displ, hwy, col = cyl)) + geom_point(size = 2,aes(shape = factor(cyl))) + theme(legend.box.margin = margin(0.3,0.3,0.3,0.3,"cm"),legend.background = element_rect(color = "yellow")) + guides(shape = guide_legend(title = "cyl")) + scale_shape_discrete(labels = c("a","b","c","d")) + theme(legend.position = "bottom") + guides(shape = guide_legend(order = 2),col = guide_legend(order = 1))