Search code examples
rplotcolorspoint

Color coding plot


I have made this plot:

plot(prey$snake.SVL, prey$prey.weight, col = prey$snake.id, pch = 20, cex = 2)

This plot shows the SVL(length of snake)VS prey weight pr.snake.id:

enter image description here

The problem is how do I get a color for each snake?


Solution

  • library(ggplot2)
    ggplot(data = snake.svl, aes(x = snake.svl,y = prey.weight, col = snake.id)) + geom_point()