0
,我有以下數據:刪除和編輯雙圖例文本GGPLOT2
metric_list <- c(0.6, 0.2, 0.1, 0.05)
terms_used = c("a", "b", "c", "d")
,我使用下面的代碼來獲得一個情節:
df <- data.frame(x = 1:length(metric_list),
terms_used = terms_used,
metric_list = 100*metric_list,
cumulative = cumsum(100*metric_list))
gplot <- ggplot(data = df, aes(x = x)) +
geom_point(aes(y = metric_list,
color = "ERR"),
size = 3) +
geom_text(aes(y = metric_list,
label = terms_used),
size = 6,
hjust = -1,
vjust = 0) +
geom_line(aes(y = cumulative,
color = "ESR",
linetype = "ESR"),
size = 1) +
geom_point(aes(y = cumulative,
color = "ESR",
shape = "ESR"),
size = 3) +
scale_colour_manual(name = "Legend",
values = c("ERR" = "blue", "ESR" = "red")) +
scale_linetype_manual(name = "Legend",
values = c("ERR" = 0, "ESR" = "dashed")) +
scale_shape_manual(name = "Legend",
values = c("ERR" = 1, "ESR" = 0))
我得到的是以下幾點:
我想知道如何修改的傳說,使得只有一個藍點(爲ERR),並用空心方形紅色線(用於ESR)出現。任何幫助是極大的讚賞。
非常感謝您的時間和幫助!真的很好的解釋。使用ggplot時,我忘記了這個「良好實踐」。此外,感謝您分享的鏈接。 – jroberayalas 2015-03-02 19:16:43