gpt4 book ai didi

r - 通过超过 2 种定义颜色的渐变以连续比例填充或着色

转载 作者:行者123 更新时间:2023-12-02 15:12:56 25 4
gpt4 key购买 nike

是否可以通过不止低和高定义的参数来制作颜色渐变?

让我们说,关于这个数据:

df <- data.frame(a = 1:100, 
b = rnorm(100, mean = 1000, sd = 500))
ggplot(df) +
geom_point(aes(a, b)) +
scale_fill_continous(low = "white", high = "black")
## as "low" and "high" is all scale_fill_continous() funcion offer

设置低和高参数只会导致线性颜色渐变,但我想要更多的组合颜色渐变,比如从白色到蓝色再到黑色。

感谢您的关注和解答。

最佳答案

你可以试试:

set.seed(123)
df <- data.frame(a=1:100, b=rnorm(100, mean = 1000, sd = 500))
ggplot(df,aes(x=a, y=b, col=b)) + geom_point() +
scale_colour_gradientn(colours = c("green", "blue","blue", "red","red", "yellow"),breaks = c(0,1000,2000,3000), limits=c(0,3000))

enter image description here

关于r - 通过超过 2 种定义颜色的渐变以连续比例填充或着色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42271113/

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