2
我已創建使用geom_smooth一個簡單的圖形:GGPLOT2:geom_smooth顏色與scale_colour_brewer
test.dat <- data.frame(matrix(c(runif(20, 0, 20)), 10, 2))
names(test.dat) <- c("x", "y")
test.plot <- ggplot(test.dat, aes(x,y)) + geom_point() +
geom_smooth(method="loess")
所產生是通過默認藍色的線。我可以通過添加此手動將其更改爲給定的顏色:
test.plot + geom_smooth(method="loess", colour="black")
不過,我想基礎上,我已經使用了一系列情節的調色板上的顏色選擇。 (不使用scale_fill_brewer代替也不)
scale_colour_brewer(type = "div", palette = "Spectral")
然而,這並沒有任何效果:通常,這將是通過將各行來實現的。我發現了一些顏色爲here的geom_smooth行爲的一些討論,但對於這個特定問題沒有明顯的解決方法。有什麼建議麼?
謝謝,那真是太棒了。如果沒有看到這種'顏色=真'的方式在之前把東西放進去;現在我明白了我是如何陷入困境的。再次感謝! – simoncolumbus 2014-11-05 13:55:41
@simoncolumbus,如果這回答你的問題,請考慮檢查它的答案。 – BrodieG 2014-11-05 15:04:08