@prardhana,
Use scale_fill/color/size_discrete/contin....(labels = c()). compare both to see the difference.
Example -
ggplot(mpg, aes(displ, hwy, fill = factor(cyl))) + geom_bar(stat = "identity") + scale_fill_discrete(labels =
c("a","b","c","d")) + theme(legend.background = element_rect(colour = "red"),plot.background = element_rect(
color = "blue"),panel.background = element_rect(color = "green"),legend.text = element_text(color = "hotpink")
,legend.title = element_text(color = "pink"))
ggplot(mpg, aes(displ, hwy, fill = factor(cyl))) + geom_bar(stat = "identity") + scale_fill_discrete(labels =
c("a","c","b","d")) + theme(legend.background = element_rect(colour = "red"),plot.background = element_rect(
color = "blue"),panel.background = element_rect(color = "green"),legend.text = element_text(color = "hotpink")
,legend.title = element_text(color = "pink"))