我使用rgl.surface()创建了一个3d地图,主要是按照Shane在这篇文章中的回答.使用我自己的数据,我得到了这张地图

在这张表面地图的顶部,我想添加一张植被密度图,这样我就可以获得这样的东西(用Surfer软件获得):

是否可以使用rgl执行此操作,或者对于r中的任何其他包或者是唯一的解决方案,有两个地图,如Shane的答案?
谢谢.
编辑:
根据@ gsk3的请求,以下是此地图的代码:
library(rgl)
# Read the z (i.e. elevation) dimension from file
z1 = matrix(scan("myfile.txt"),nrow=256, ncol=256, byrow=TRUE)
#create / open x y (i.e. easting and northing coordinates) dimensions
y=8*(1:ncol(z)) # Each point is 8 m^2
x=8*(1:nrow(z))
# See https://stackoverflow.com/questions/1896419/plotting-a-3d-surface-plot-with-contour-map-overlay-using-r for details of code below
zlim <- range(z)
zlen <- zlim[2] - zlim[1] + 1
colorlut <- terrain.colors(zlen,alpha=0) # height color lookup table
col <- colorlut[ z-zlim[1]+1 ] # assign colors to heights for …Run Code Online (Sandbox Code Playgroud) 说我有以下矩阵:
x1 = 1:288
x2 = matrix(x1,nrow=96,ncol=3)
Run Code Online (Sandbox Code Playgroud)
是否有一种简单的方法可以获得第2列的行1:24,25:48,49:72,73:96的平均值?
基本上我有一年的时间序列,我必须每24小时平均一些数据.
我正在尝试使用该命令在我的笔记本电脑(Ubuntu 12.04)上安装RNetCDF软件包
install.packages('RNetCDF',lib='/home/my_computer/RSCRIPTS/R_LIB/',configure.args="--with-netcdf-include='/home/my_computer/bin/libs4cdo-0.0.10/netcdf-4.2/include/' --with-netcdf-lib='/home/my_computer/local/bin' --with-hdf5-lib='/home/my_computer/local/lib/' --with-udunits-include='/usr/local/lib/' --with-udunits-lib='/usr/local/lib/'",repos='http://star-www.st-andrews.ac.uk/cran/')
Run Code Online (Sandbox Code Playgroud)
但是包不会安装.请参阅以下消息:
trying URL 'http://star-www.st-andrews.ac.uk/cran/src/contrib/RNetCDF_1.6.1-2.tar.gz'
Content type 'application/x-gzip' length 70301 bytes (68 Kb)
opened URL
==================================================
downloaded 68 Kb
* installing *source* package ‘RNetCDF’ ...
** package ‘RNetCDF’ successfully unpacked and MD5 sums checked
checking for gcc... gcc -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o …Run Code Online (Sandbox Code Playgroud) 我需要在r中绘制一个90度的圆.我知道如何在R中绘制一个完整的圆圈,draw.circle但我不知道如何隐藏它的270度!
谢谢.
道歉,我认为会有一个非常明显的答案,但我在网上找不到任何东西......
我经常得到非常大的数据集,其中缺失值是空白的,例如(简而言之)
#Some description of the dataset
#cover x number of lines
31 3213 313 64 63
31 3213 313 64 63
31 3213 313 64 63
31 3213 313 64 63
31 3213 313 64 63
12 178 190 865
532 31 6164 68
614 131 864 808
Run Code Online (Sandbox Code Playgroud)
我想用例如-999替换所有空格.如果我使用这样的读表
dat = read.table('file.txt',skip=2)
Run Code Online (Sandbox Code Playgroud)
我收到错误消息
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
line 6 did not have 5 elements
Run Code Online (Sandbox Code Playgroud)
我可以将文件作为数据框打开并执行
dat = data.frame('file.txt',skip=2)
is.na(rad1) = which(rad1 …Run Code Online (Sandbox Code Playgroud) 我有以下代码
frame()
Y = read.table("Yfile.txt",header=T,row.names=NULL,sep='')
X = read.table("Xfile.txt",header=F,sep='')
plot(Y$V1~X$V1,pch=20,xlim=c(0,27))
par(new=T)
plot(Y$V1~X$V2,pch=20,xlim=c(0,27),col='red')
par(new=T)
plot(Y$V1~Y$V3,pch=20,xlim=c(0,27),col='blue')
par(new=T)
Run Code Online (Sandbox Code Playgroud)
一切都很好,我在同一个图上得到了3张图.但是,当我想划分X $ V1,X $ V2和X $ V3来规范化数据时
plot(Y$V1~X$V1/Y$V2,pch=20,xlim=c(0,27))
par(new=T)
plot(Y$V1~X$V2/Y$V2,pch=20,xlim=c(0,27),col='red')
par(new=T)
plot(Y$V1~Y$V3/Y$V2,pch=20,xlim=c(0,27),col='blue')
par(new=T)
Run Code Online (Sandbox Code Playgroud)
我收到了消息
点击返回查看下一个图:
并且图表不会显示在同一个图中.谁能告诉我发生了什么以及如何解决它?
我试图控制contourplot()在格子库中绘制的轮廓图中应该写入多少z个标签.
我有30条轮廓线,但我只希望标记前5条.我尝试了很多类似的东西
contourplot(z ~ z+y, data=d3, cuts=30, font=3, xlab="x axis", ylab="y axis", scales=list(at=seq(2,10,by=2)))
contourplot(z ~ z+y, data=d3, cuts=30, font=3, xlab="x axis", ylab="y axis", at=seq(2,10,by=2))
Run Code Online (Sandbox Code Playgroud)
但没有任何作用.
此外,是否可以contourplot()在同一图表上绘制两个?我试过了
contourplot(z ~ z+y, data=d3, cuts=30)
par(new=T)
contourplot(z ~ z+y, data=d3, cuts=20)
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
谢谢!
我正在使用以下代码创建调色板:
library(rgl)
fv.colors = colorRampPalette(c("white","tan4","green"))
colorlut = terrain.colors(100)[c(100,95,90,85,80,75:30,25,20,15,14:1)]
col = colorlut[fv-trnlim[1]+1 ]
Run Code Online (Sandbox Code Playgroud)
这给出了:(颜色条是按照这里提供的代码创建的)

我想要的是一条白色的条带,正如我现在所拥有的那样,然后在0.01处干净的休息时间,调色板将从"tan4" 开始,而不是现在的状态,即逐渐从白色到"tan4"(实际上,它没有像tan4那样变暗).
抱歉,如果这是一个非常简单的答案,但经过多次尝试和大量的谷歌搜索,我仍然无法解决它.
谢谢!
可能重复:
如何按R中的列对数据帧进行排序
我有一个如下所示的数据集:
x y z
1. 1 0.2
1.1 1 1.5
1.2 1 3.
1. 2 8.1
1.1 2 1.0
1.2 2 0.6
Run Code Online (Sandbox Code Playgroud)
我想要的是首先将数据集作为x的函数按递增顺序组织,然后作为y的函数来组织
x y z
1. 1 0.2
1. 2 8.1
1.1 1 1.5
1.1 2 1.
1.2 1 3.
1.2 2 0.6
Run Code Online (Sandbox Code Playgroud)
我知道apply,mapply,tapply等函数重新组织数据集,但我必须承认我并不真正理解它们之间的差异,也不知道如何应用哪些以及何时应用.
谢谢你的建议.
我有一个带标题的文本文件数据集
YEAR MONTH DAY value
Run Code Online (Sandbox Code Playgroud)
从2010年6月6日至2012年7月14日每小时运行一次.我使用以下命令打开并绘制数据:
data=read.table('example.txt',header=T)
time = strptime(paste(data$DAY,data$MONTH,data$YEAR,sep="-"), format="%d-%m-%Y")
plot(time,data$value)
Run Code Online (Sandbox Code Playgroud)
但是,绘制数据时,x轴仅显示2011年和2012年.
.如何保留2011年和2012年的标签,还要添加一些特定的月份,例如,如果我想要3月,6月和9月?
我已在此链接上提供数据