ggplot2与scale_brewer相反的顺序 [英] ggplot2 reverse order of scale_brewer
问题描述
如何反转颜色顺序?通过查看 scale_brewer 的文档,我想它可以是 formatter =
参数可疑。我传递了'rev'
,然后 rev
,但它们没有任何影响(没有错误消息,只是忽略了)。
我想你可能想使用 brewer.pal
直接使用 scale_colour_manual
:
ggplot(mtcars,aes(x = $ m
$(
$)
$ $ b
然后您可以 从ggplot版本2.0.0开始,现在有一种更直接的方法可以做到这一点,请参阅下面的@pbaylis的答案。 Seemingly a very simple thing to do but it took me >30min without finding answer. How do I reverse the order of colors? By looking at documentation for scale_brewer, i figured it can be I think you probably want to select the colors using Then you can As of version 2.0,0 of ggplot there is now a more direct way to do this, see the answer by @pbaylis below. 这篇关于ggplot2与scale_brewer相反的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
formatter=
argument being suspicious. I passed 'rev'
and then rev
, but they have no effect (no error message, just ignored).brewer.pal
directly and then use scale_colour_manual
:ggplot(mtcars,aes(x = mpg, y = disp)) +
geom_point(aes(colour = factor(cyl))) +
scale_colour_manual(values = rev(brewer.pal(3,"BuPu")))
rev
the order of the colors there.