3
我試圖從Hadley Wickham的ggplot2 book複製圖6.11,它繪製了Luv空間中的R顏色;點的顏色代表自己,沒有傳說是必要的。 繪製Luv顏色;從ggplot2書複製圖6.11
這裏有兩個企圖:
library(colorspace)
myColors <- data.frame("L"=runif(10000, 0,100),"a"=runif(10000, -100, 100),"b"=runif(10000, -100, 100))
myColors <- within(myColors, Luv <- hex(LUV(L, a, b)))
myColors <- na.omit(myColors)
g <- ggplot(myColors, aes(a, b, color=Luv), size=2)
g + geom_point() + ggtitle ("mycolors")
第二次嘗試:
other <- data.frame("L"=runif(10000),"a"=runif(10000),"b"=runif(10000))
other <- within(other, Luv <- hex(LUV(L, a, b)))
other <- na.omit(other)
g <- ggplot(other, aes(a, b, color=Luv), size=2)
g + geom_point() + ggtitle("other")
有幾個明顯的問題s:
- 這些圖看起來不像這個圖。任何建議 代碼需要?
- 第一次嘗試在Luv 列中生成大量NA字段(在10,000次運行中只有約3100個命名顏色,而在第二次運行中只有約9950個在 中)。如果L應該介於0-100和u之間,並且在012-之間介於-100和100之間,爲什麼我在第一次運行時有這麼多的NA?我試過四捨五入,但沒有幫助。
- 爲什麼我有傳說?
非常感謝。
就是這樣,謝謝! – koenbro 2013-02-12 07:29:49
或更好,請使用'scale_colour_identity' – hadley 2013-02-12 13:54:15
@hadley。我不知道該怎麼做。 'ggplot(DF,aes(x = U,y = V,fill = colors()))+ geom_point()+ scale_color_identity()'不起作用 - 給出黑點和標籤。你能否展示一個可重複使用的小例子?謝謝 – koenbro 2013-02-12 21:31:30