gpt4 book ai didi

r - persp() : what is wrong with my color?

转载 作者:行者123 更新时间:2023-12-04 10:28:50 26 4
gpt4 key购买 nike

我正在尝试根据我拥有的数据以经度/纬度格式创建透视图。

enter image description here

纬度和经度绘制正确,但背景是奇怪的黑色。我怎么能改变它。

persp(lga_crop_05, expand =0.5, phi = 35, col= "lightblue", ticktype = "detailed")

这就是我创建情节的代码。 lga_crop_05 是我的栅格图层,其中包含我在上面附加的绘图的纬度/经度/值。

如果有任何帮助,我将不胜感激。谢谢

最佳答案

出了什么问题?

代码没有问题;但用我们的眼睛。试试下面的代码:

## a function to produce a perspective plot
## "n" controls how refined your grid is
foo <- function(n) {
x <- seq(-1.95, 1.95, length = n)
y <- seq(-1.95, 1.95, length = n)
z <- outer(x, y, function(a, b) a*b^2)
persp(x, y, z, col = "lightblue")
}

如果我们有一个 10 * 10 的网格,颜色看起来很完美。

foo(10)

nice

如果我们有一个 100 * 100 的网格,颜色看起来还可以。

foo(100)

ok

现在,如果我们有非常精细的数据,例如,在 1000 * 1000 的网格上。一切都会看起来像黑色。

 foo(1000)

oh no!

请注意,您有一个栅格。我怀疑您的数据过于精细。您是否检查过 lga_crop_05 中有多少个单元格?

如何出行?

设置 border = NA。尝试修改功能:

foo1 <- function(n) {
x <- seq(-1.95, 1.95, length = n)
y <- seq(-1.95, 1.95, length = n)
z <- outer(x, y, function(a, b) a*b^2)
persp(x, y, z, col = "lightblue", border = NA)
}

Great

关于r - persp() : what is wrong with my color?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37752320/

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