【发布时间】:2017-07-21 22:37:29
【问题描述】:
当我在 R 中使用 ggplot2 时,我无法更改我的图例标签。我绘制了一个折线图,其中包含 7 条线,对应于温度区 (x) 上的进料策略 (y) 的样本比例。到目前为止,我已经尝试使用 2 种不同的方法来更改标签(目前是 1-7),但都没有改变任何东西。这些是我尝试过的:
plot + scale_fill_discrete("Feeding Type",breaks=c("1", "2", "3", "4", "5", "6", "7"),
labels=c("Fungivorous", "Herbivorous", "Saprophagous", "Predacious", "Xylophagous", "Parasitoid", "Algivorous"))
和
plot + scale_shape_manual("Feeding Type",breaks=c("1", "2", "3", "4", "5", "6", "7"),
labels=c("Fungivorous", "Herbivorous", "Saprophagous", "Predacious", "Xylophagous", "Parasitoid", "Algivorous"))
【问题讨论】:
-
我不会尝试在 ggplot 调用中更正标签。首先考虑变量并应用标签/级别和顺序。
标签: r ggplot2 legend legend-properties