Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R光栅包plot()生成单色图像_R_Plot_Raster_Monochrome - Fatal编程技术网

R光栅包plot()生成单色图像

R光栅包plot()生成单色图像,r,plot,raster,monochrome,R,Plot,Raster,Monochrome,我想得到单色图像使用绘图功能。但它一直在生成彩色图像。我甚至用plot函数绘制了单色图像,得到了一些奇怪的绿色和橙色。如何使绘图功能提供单色图像?我试图阅读有关getValues函数的内容,但发现很难理解,因为我不是图像分析背景。getBlocks()函数似乎返回单色图像。但是,有没有一种方法仅仅使用绘图功能就可以获得单色图像呢 library(raster) r <- raster(matrix(runif(100), 10)) plot(r) #even below lines pro

我想得到单色图像使用绘图功能。但它一直在生成彩色图像。我甚至用plot函数绘制了单色图像,得到了一些奇怪的绿色和橙色。如何使绘图功能提供单色图像?我试图阅读有关getValues函数的内容,但发现很难理解,因为我不是图像分析背景。getBlocks()函数似乎返回单色图像。但是,有没有一种方法仅仅使用绘图功能就可以获得单色图像呢

library(raster)
r <- raster(matrix(runif(100), 10))
plot(r)
#even below lines produce a yellow color image. i thought that they will produce a black or white square
r <- raster(matrix(rep(0,100), 10))
plot(r)
库(光栅)

r如果要查找颜色的灰度向量,可以使用
gray.scale()
作为
plot()中的
col
参数:


您生成的图像是单色的,因为它只包含黄色。你的意思可能是灰度。你的评论很有道理。谢谢,我能用原色(而不是绿色和黄色)绘制我的图像吗?
library(raster)
r <- raster(matrix(rnorm(100), 10))
plot(r, col = gray.colors(10, start = 0.3, end = 0.9, gamma = 2.2, alpha = NULL))
rev(terrain.colors(255))