gfg_plot <- ggplot(NULL, aes(x = Area, y = Richness, fill = District )) +
geom_point(data=District1, col="blue") +
geom_point(data=District2, col="black")+
geom_point(data=District3, col="Purple")+
geom_point(data=District4, col="Green")+
geom_point(data=District5, col="Orange")+
geom_point(data=District6, col="Cyan")+
geom_point(data=District7, col="coral")+
geom_point(data=District8, col="red")+
geom_point(data=District9, col="skyblue")+
theme_few() +
xlab("Area")+
ylab("Average richness")+
labs(title = "PingshanSAR_plot")+
scale_x_log10(breaks = trans_breaks("log10", function(x) 10^x),
labels = trans_format("log10", math_format(10^.x))) +
scale_y_log10(breaks = trans_breaks("log10", function(x) 10^x),
labels = trans_format("log10", math_format(10^.x))) +
theme(plot.title = element_text(size = 15),
legend.title = element_blank(),
legend.text = element_text(color = NULL))
plot(gfg_plot)
The outcome: main part of the plot looks just fine, but in the legend, all the points are in light blue. How can I make the colour of each legend into the colour I use for each dataset?
I also tried to add this in above, but it is not working.
scale_fill_manual(name = "District",
values = c("District1" = "blue", "District8" = "red",
"District2"= "black","District3" = "Purple", "District6" = "Cyan" ,
"District4" = "Green","District5"= "Orange", "District7"="coral",
"District9"= "skyblue"))+
I would like to find a way to change the colour of my legend and use the same colour as each dataset use without merging or manipulate the data.
Plot that I generate through above code Plot that generated from above code