是否有可能創建大號不同種類的「紅」色。爲了更好地理解,我期待跟隨,但不是灰色,我希望有「紅色」或「紅黑色」。寬範圍的相同顏色在R
mypalette <- rev(grey.colors(10000, start = 0.1, end = 0.5, gamma = 4))
plot(1:length(mypalette),1:length(mypalette), col=mypalette, pch=16)
顏色的包,我知道有有限的顏色範圍。任何想法將不勝感激。
是否有可能創建大號不同種類的「紅」色。爲了更好地理解,我期待跟隨,但不是灰色,我希望有「紅色」或「紅黑色」。寬範圍的相同顏色在R
mypalette <- rev(grey.colors(10000, start = 0.1, end = 0.5, gamma = 4))
plot(1:length(mypalette),1:length(mypalette), col=mypalette, pch=16)
顏色的包,我知道有有限的顏色範圍。任何想法將不勝感激。
如果我明白你想要的,試試colorRampPalette
。它會返回一個函數,用於輸出您指定的兩個顏色之間所請求的顏色數量。
reds <- colorRampPalette(c("black","red"))
reds(5)
[1] "#000000" "#3F0000" "#7F0000" "#BF0000" "#FF0000"
這就是我想要的!非常感謝。 –
這裏有一些ggplot
替代
library(ggplot2)
df <- data.frame(x = rnorm(100), y = rnorm(100), z = rnorm(100), z2 = factor(1:5))
# colour set by continuous variable
ggplot(data = df, aes(x = x, y = y, colour = z)) +
geom_point() +
scale_colour_gradient(low = "red", high = "white")
library(RColorBrewer)
ggplot(data = df, aes(x = x, y = y, colour = z)) +
geom_point() +
scale_colour_gradientn(colours = brewer.pal(5, "Reds"))
# colour set by discrete variable
ggplot(data = df, aes(x = x, y = y, colour = z2)) +
geom_point() +
scale_colour_brewer(palette = "Reds")
'''plot.'包的'color.gradient(c(1,1),c(1,0),c(0,0),nslices = 10)' – Zbynek