Reputation: 397
I'm plotting two vectors with ggplot and want to color the resulting discrete points regarding their superpopulation tags (6 superpops in total, and using my personal color palette mypal). I have a data frame called newPC2 that has three columns: PC1 (x vector), PC2 (y vector), and Superpop (population tags, "EUR", "AMR"). When I try to do the following:
mypalette=c("blue","violetred1","green1","darkorchid1","yellow1","black")
ggplot(newPC2, aes(PC1, PC2, fill=Superpopulations2)) +
geom_point(size = 2.5) +
scale_color_manual(values = mypalette) +
theme(legend.position="bottom")
All the graph dots appear in black. I want the dots colored in one of 6 colors representing its superpopulations, to see how they distribute (they're PCA results).
Any thoughts? Thank you !
Upvotes: 1
Views: 721
Reputation: 697
The default point geometry in ggplot
is 16 (a dot) and so does not have a fill aesthetic, only a color. This means you will have to map the SuperPopulations2 variable onto color, ultimately with code that looks something like this:
ggplot(newPC2, aes(PC1, PC2, color=Superpopulations2)) +
geom_point(size = 2.5) +
scale_color_manual(values = mypalette) +
theme(legend.position="bottom")
This site has some pretty helpful information about using shapes.
Upvotes: 1