我正在尝试使用scale_color_brewer(direction = -1)
来颠倒图的颜色映射。但是,这样做也会更改调色板。如何颠倒ggplot2的默认调色板
library(ggplot2)
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species))+geom_point()
# reverse colors
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species))+geom_point()+
scale_color_brewer(direction = -1)
潜在的解决方案
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species))+geom_point()+
scale_color_brewer(direction = -1, palette = ?)
已更新标题 – Ben
没有答案,但默认比例是“scale_color_discrete”,而不是颜色啤酒比例。它调用'discrete_scale'指定调色板为'scales :: hue_pal',并且* does *采用'direction'参数,但是添加'scale_color_discrete(direction = -1)'不仅仅是改变调色板。现在没有时间挖掘更多... – Gregor