2016-12-12 79 views
2

我在R自我教學中遇到了一些問題。我希望這裏有人能提供幫助,因爲我在Google上找不到解決方案。R中的顏色強度錯誤

我試圖將一些基本的顏色參數應用到plot命令。我的基本代碼看起來會是:

plot(dose,drugA, type = "b", lty = 2, pch = 18, cex = 1.5, lwd = 1.25, col = rgb(43,228,178), col.axis = rgb(11,114,86), col.lab = rgb(95,195,168), fg = rgb(222,92,53), bg = rgb(222,216,53))

或者:

par(lty = 2, pch = 18, cex = 1.5, lwd = 1.25, col = rgb(43,228,178), col.axis = rgb(11,114,86), col.lab = rgb(95,195,168), fg = rgb(222,92,53), bg = rgb(222,216,53))

每次我用這個代碼,我收到以下錯誤信息:

在RGB錯誤(43,228,178):顏色強度43,不在[0,1]中

任何幫助將不勝感激。

回答

3

默認情況下,rgb將R,G,B值設置爲0和1之間的值。你可以得到你想要的效果rgb(43/255, 228/255, 178/255)

+3

你說的對,但'rgb'也有'maxColorValue ='參數 - 所以你可以做'rgb(43,228,178,maxColorValue = 255) ' – thelatemail