gpt4 book ai didi

r - ggplot2 与scale_brewer 的顺序相反

转载 作者:行者123 更新时间:2023-12-03 01:23:57 25 4
gpt4 key购买 nike

看似非常简单的事情,但我花了 30 分钟以上才找到答案。

如何颠倒颜色顺序?通过查看documentation for scale_brewer ,我认为可能是 formatter= 参数可疑。我依次传递了 'rev'rev,但它们没有任何效果(没有错误消息,只是被忽略)。

最佳答案

ggplot2 的 CRAN 版本现在允许用户在 scale_brewer 中指定 direction=-1反转颜色。以下产生与接受的答案相同的情节。

ggplot(mtcars,aes(x = mpg, y = disp)) + 
geom_point(aes(colour = factor(cyl))) +
scale_colour_brewer(palette="BuPu", direction=-1)

关于r - ggplot2 与scale_brewer 的顺序相反,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8750871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com