0

I want to color the points by group in ggplot. Used lot of options but nothing helped and the points still black or have a another single color. I found the option to set inherit.aes = FALSE, but that don't helped and still have the Error "Error in FUN(X[[i]], ...) object 'Legend' not find" That's my Code:

theme_set(
  theme_minimal() +
    theme(legend.position = "right")
)

scores$condition <- c(rep("Col.mock", 6), rep("Col.treated", 6), rep("sid2.mock", 3), rep("sid2.treated", 3), rep("ald1.mock", 3), rep("ald1.treated", 3))

pca_p<-ggplot(data = scores, aes(x=PC1, y=PC2, color = Legend)) +
  geom_point(size=3) + geom_text_repel(aes(label=condition), size=3) +
  labs(x= paste0("PC1 (", s$importance[2,1]*100,"%)"),
       y= paste0("PC2 (", s$importance[2,1]*100, "%)"))
pca_p 

If I delete the "color= Legend" everything works, except the colors what I also want to have is a legend, but that doesn't work at all Can please someone help me?

ThunderMX
  • 5
  • 1
  • 1
    Do you have a column named "Legend" in your data? Or are you trying to color by this "condition" column? Maybe you want `color=condition`. It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick May 02 '20 at 21:52

1 Answers1

0

The argument color Should point at one of your variables (columns in the data frame), in the same way that you have x and y pointing at the variables PC1, PC2. Maybe try color=condition or show some example of your data frame and how exactly you want to color the dots and we can help you more.