Color coding scatter plot (PCA)

I'm using the following code to seperatly color code my 3 groups in r:

pca_ggp = ggplot(pca_coordinates, aes(x=PC1, y=PC2)) + geom_point() +
scale_colour_manual(values=c("red", "blue", "green"))

However, all the dots come back black.

Can anyone please help,

all the best.

Can you please share what your data looks like? One way would be to paste in what you get from dplyr::glimpse(pca_coordinates).

Actually I have been trying to implement the same where I have two numeric columns x and y and I want to plot those points using different color and size. I went ahead to plot line chart with points for them , but it didn't seem to differentiate the points of x and y. Meanwhile data looks like this.

dplyr::glimpse(comData)
Rows: 8
Columns: 2
x <dbl> 0.4177, 10.3630, 0.7201, 0.2004, -0.8227, 0.9485, -0.0071, 1.0090 y 0.3706, 9.4265, 0.7227, 0.2009, -0.7709, 0.9566, -0.0075, 1.0153

Do you have a column that codes the groups in your pca_coordinates? I guess not.
Maybe you need to merge the results from the PCA with your input.
When you have this column, you need to define this in the aes() statement,
ggplot(pca_coordinates, aes(x=PC1, y=PC2, colour = group))
See comment from scottyd22 to show us how your data looks like.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.