gpt4 book ai didi

r - Hexbin 包装内需要特定颜色?

转载 作者:行者123 更新时间:2023-12-01 11:45:40 24 4
gpt4 key购买 nike

我正在绘制高密度点的散点图。我使用了 Hexbin 包并成功绘制了数据。颜色不漂亮,我被要求遵循标准颜色。我想知道 R 是否支持它。图像显示了我的输出(右)和想要的颜色(左)。 enter image description here

例子:

    x <- rnorm(1000)
y <- rnorm(1000)
bin<-hexbin(x,y, xbins=50)
plot(bin, main="Hexagonal Binning")

最佳答案

使用 hexbin 包 helpapge 上的示例,您可以接近使用 rainbow 并像这样使用 colcuts 参数...

x <- rnorm(10000)
y <- rnorm(10000)
(bin <- hexbin(x, y))

plot(hexbin(x, y + x*(x+1)/4),main = "Example" ,
colorcut = seq(0,1,length.out=64),
colramp = function(n) rev(rainbow(64)),
legend = 0 )

enter image description here

您将需要使用图例规范等来获得您想要的。

@Roland 建议的替代调色板

## nicer colour palette
cols <- colorRampPalette(c("darkorchid4","darkblue","green","yellow", "red") )
plot(hexbin(x, y + x*(x+1)/4), main = "Example" ,
colorcut = seq(0,1,length.out=24),
colramp = function(n) cols(24) ,
legend = 0 )

enter image description here

关于r - Hexbin 包装内需要特定颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15573871/

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