I have generated the following code for a plot:
ggplot(Table_Final_v0, aes(x=log2(SeqCount_a+1), y=log2(SeqCount_m1+1), fill=kingdom2, color=Color_point2)) +
geom_point(size=Size_point, alpha=0.8, color=Color_point2) + scale_color_manual(values = Color_point2) +
theme_classic() + ylab("log2(Sequence Count -m 1)\n") + xlab("\nlog2(Sequence Count -a)") + ylim(0,14) + xlim(7,17) +
geom_text(label=species, nudge_x = -0.5, nudge_y = 0.5, check_overlap = T, show.legend = F, color="black") +
theme(axis.text.x = element_text(size=10), axis.title=element_text(size=12),
axis.text.y =element_text(size=10),plot.margin = margin(1, 0.5, 0.5, 1, "cm")) + ggtitle(title) +
theme(plot.title = element_text(size = 14)) + theme(legend.title=element_blank())
Which generates the following plot:
And the Table_Final_v0 looks like this:
rRNA Seq_count_m1 Seq_count_a Size_point species kingdom2 Color_point2
Loxodonta_africana 178 18722 6 Laf Elephant red3
Acyrthosiphon_pisum 0 50324 4 Api Insects dodgerblue3
Aedes_aegypti 0 36776 4 Aae Insects dodgerblue3
Aegilops_tauschii 26 17539 4 Ata Plants forestgreen
. . . . . . .
. . . . . . .
As you can see, the kingdom2 variable contains the names appearing in the legend, and the Color_point2 variable includes the colors I would like to display in the plot and also in the legend. But somehow I could not manage to assign them to the legend, and they only appear in the plot.
What is wrong with the code? I would like the colors to appear as well in each label in the legend like it should be doing with scale_color_manual

