我在 ggplot2
上应用两个不同的更改时遇到问题目的。我有一个带有 3 个组的条形图。我想要:
针对上述问题,我找到了以下解决方案:
+ scale_fill_manual(values = c("red", "green", "blue"))
+ scale_fill_discrete(guide = guide_legend(reverse=TRUE))
问题是第二个应用程序(
+ scale_fill_discrete(...)
)覆盖了第一个应用程序:Scale for 'fill' is already present. Adding another scale for 'fill', which will replace the existing scale.
(分别它们都可以正常工作)。如何处理?
最佳答案
你不需要把它加倍,这应该有效:
scale_fill_manual(values = c("red", "green", "blue"), name = "My name",
guide = guide_legend(reverse = TRUE))
关于r - scale_fill_discrete 和 scale_fill_manual - 图例选项混淆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25176399/