2015-10-15 26 views
1

顏色我已經取得該地塊編碼情節

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

此圖顯示了SVL(蛇的長度)VS獵物重量pr.snake.id:

enter image description here

的問題是我如何獲得每條蛇的顏色?

+0

在繪圖之前設置調色板(彩虹(長度(獨特(獵物$ snake.id))))。我認爲'調色板(「默認」)只有8種顏色。 – lukeA

回答

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

ggplot可能是更好的陰謀打賭。

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

這可能不完全正確,但它應該可以幫助您開始。

重點是ggplot和geom_point會給你你想要的。