2
我使用下面的代碼來生成一個簡單的圖表:從ggplot圖例中刪除元素繪製與多個AES設置面時
# Data and libs
data(mtcars)
reuire(ggplot2); require(ggthemes)
# Chart def
ggplot(mtcars, aes(wt, mpg, colour = as.factor(vs))) +
geom_point(aes(colour = factor(cyl))) +
facet_wrap(~ cyl) +
guides(colour = guide_legend(title = "Something")) +
geom_smooth(method = "lm", se = FALSE) +
theme_pander()
如何可以從除去線傳說?我感興趣的圖例只顯示了帶有相應顏色的點,而沒有來自geom_smooth(method = "lm", se = FALSE)
的線條。
我看了一下這個問題上Turning off some legends in a ggplot,但是,看完後,這是我不清楚如何禁用屬於特定geom
傳奇元素。
[在ggplot關閉一些傳說]的可能重複(HTTP:/ /stackoverflow.com/questions/14604435/turning-off-some-legends-in-a-ggplot) – scoa
將'show_guide = FALSE'添加到'geom_smooth' – scoa
@scoa'show_guide'已棄用,但他可以使用show。 legend = FALSE'來代替。這實際上比我的答案簡單。 –