我正在尝试使用A true heat map in R建议,但是我收到错误:
interp.old错误(x,y,z,xo = xo,yo = yo,ncp = 0,extrap = extrap,
:x和y的尺度太不相似
代码行之后:
s <- interp(x,y,z)
我的数据构建时希望在黑暗的连续背景中获得彩色热图,并使用GNUplot
和set pm3d map
在set hidden3d
中工作。数据对应于给定时间(y
)中分子产生的模型(x
),其出现频率由z
表示。它看起来像这样:
1.000000000000e+00 1e-8 0
1.000000000000e+00 5e-8 0
1.000000000000e+00 1e-7 5
1.000000000000e+00 5e-7 0
1.000000000000e+00 1e-6 0
1.000000000000e+00 5e-6 0
1.000000000000e+00 1e-5 0
1.000000000000e+00 5e-5 0
1.000000000000e+00 1e-4 0
1.000000000000e+00 5e-4 0
1.000000000000e+00 1e-3 0
1.000000000000e+00 5e-3 0
1.000000000000e+00 1e-2 0
1.000000000000e+00 5e-2 0
1.000000000000e+00 1e-1 0
1.000000000000e+00 5e-1 0
1.000000000000e+00 1e+1 0
1.000000000000e+00 5e+1 0
1.000000000000e+00 1e+2 0
1.000000000000e+00 5e+2 0
1.000000000000e+00 1e+3 0
1.000000000000e+00 5e+3 0
1.000000000000e+00 1e+4 0
1.000000000000e+00 5e+4 0
1.000000000000e+00 1e+5 0
1.000000000000e+00 5e+5 0
1.000000000000e+00 1e+6 0
1.000000000000e+00 5e+6 0
1.000000000000e+00 1e+7 0
1.000000000000e+00 5e+7 0
1.000000000000e+00 1e+8 0
1.000000000000e+00 5e+8 0
2.000000000000e+00 1e-8 0
2.000000000000e+00 5e-8 0
2.000000000000e+00 1e-7 0
2.000000000000e+00 5e-7 5
2.000000000000e+00 1e-6 0
2.000000000000e+00 5e-6 0
2.000000000000e+00 1e-5 0
2.000000000000e+00 5e-5 0
2.000000000000e+00 1e-4 0
2.000000000000e+00 5e-4 0
2.000000000000e+00 1e-3 0
2.000000000000e+00 5e-3 0
2.000000000000e+00 1e-2 0
2.000000000000e+00 5e-2 0
2.000000000000e+00 1e-1 0
2.000000000000e+00 5e-1 0
2.000000000000e+00 1e+1 0
2.000000000000e+00 5e+1 0
2.000000000000e+00 1e+2 0
2.000000000000e+00 5e+2 0
2.000000000000e+00 1e+3 0
2.000000000000e+00 5e+3 0
2.000000000000e+00 1e+4 0
2.000000000000e+00 5e+4 0
2.000000000000e+00 1e+5 0
2.000000000000e+00 5e+5 0
2.000000000000e+00 1e+6 0
2.000000000000e+00 5e+6 0
2.000000000000e+00 1e+7 0
2.000000000000e+00 5e+7 0
2.000000000000e+00 1e+8 0
2.000000000000e+00 5e+8 0
3.000000000000e+00 1e-8 0
3.000000000000e+00 5e-8 0
3.000000000000e+00 1e-7 0
3.000000000000e+00 5e-7 0
3.000000000000e+00 1e-6 5
3.000000000000e+00 5e-6 0
3.000000000000e+00 1e-5 0
3.000000000000e+00 5e-5 0
3.000000000000e+00 1e-4 0
3.000000000000e+00 5e-4 0
3.000000000000e+00 1e-3 0
3.000000000000e+00 5e-3 0
3.000000000000e+00 1e-2 0
3.000000000000e+00 5e-2 0
3.000000000000e+00 1e-1 0
3.000000000000e+00 5e-1 0
3.000000000000e+00 1e+1 0
3.000000000000e+00 5e+1 0
3.000000000000e+00 1e+2 0
3.000000000000e+00 5e+2 0
3.000000000000e+00 1e+3 0
3.000000000000e+00 5e+3 0
3.000000000000e+00 1e+4 0
3.000000000000e+00 5e+4 0
3.000000000000e+00 1e+5 0
3.000000000000e+00 5e+5 0
3.000000000000e+00 1e+6 0
3.000000000000e+00 5e+6 0
3.000000000000e+00 1e+7 0
3.000000000000e+00 5e+7 0
3.000000000000e+00 1e+8 0
3.000000000000e+00 5e+8 0
4.000000000000e+00 1e-8 0
4.000000000000e+00 5e-8 0
4.000000000000e+00 1e-7 0
4.000000000000e+00 5e-7 0
4.000000000000e+00 1e-6 0
4.000000000000e+00 5e-6 5
4.000000000000e+00 1e-5 0
4.000000000000e+00 5e-5 0
4.000000000000e+00 1e-4 0
4.000000000000e+00 5e-4 0
4.000000000000e+00 1e-3 0
4.000000000000e+00 5e-3 0
4.000000000000e+00 1e-2 0
4.000000000000e+00 5e-2 0
4.000000000000e+00 1e-1 0
4.000000000000e+00 5e-1 0
4.000000000000e+00 1e+1 0
4.000000000000e+00 5e+1 0
4.000000000000e+00 1e+2 0
4.000000000000e+00 5e+2 0
4.000000000000e+00 1e+3 0
4.000000000000e+00 5e+3 0
4.000000000000e+00 1e+4 0
4.000000000000e+00 5e+4 0
4.000000000000e+00 1e+5 0
4.000000000000e+00 5e+5 0
4.000000000000e+00 1e+6 0
4.000000000000e+00 5e+6 0
4.000000000000e+00 1e+7 0
4.000000000000e+00 5e+7 0
4.000000000000e+00 1e+8 0
4.000000000000e+00 5e+8 0
第一个建议给了我一些丑陋的结果,类似于A true heat map in R中首先获得的结果,这是一个曲线,其中一些水平线在不同的灰度色调中充满了点。第二个似乎崩溃了。我收到了这条消息:
>Traceback:
1: .Fortran("idsfft", as.integer(1), as.integer(ncp), as.integer(n), as.double(x), as.double(y), as.double(z), as.integer(nx), as.integer(ny), x = as.double(xo), y = as.double(yo), z = zo, integer((31 + ncp) * n + nx * ny), double(5 * n), misso = as.logical(misso), PACKAGE = "akima")
2: interp.old(x, y, z, xo = xo, yo = yo, ncp = 0, extrap = extrap, duplicate = duplicate, dupfun = dupfun)
3: interp(x, y, z)
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
我只是提供了更多数据以防万一。 我这样用数据框调用列:
coso&lt; - read.table(“/ home / libertad / mygraphs / two / two_1_90 / coso.txt”,header = FALSE,sep =“\ t”)
>x <-coso[[1]]
>y <-coso[[2]]
这是我在GNUplot中的一个图表,我期望用R获得更好的图表。
答案 0 :(得分:4)
使用scale()
将x和y转换为可比较的比例。
使用问题中的fields
包:
library(akima)
library(fields)
x <- rnorm(20, 4, 3)
y <- rnorm(20, 5e-5, 1e-5)
x <- scale(x) # comment out these two lines
y <- scale(y) # to reproduce your error
z <- rnorm(20)
s <- interp(x,y,z)
image.plot(s)
使用ggplot2
,改编自my other answer here:
library(akima)
library(ggplot2)
x <- rnorm(20, 4, 3)
y <- rnorm(20, 5e-5, 1e-5)
x <- scale(x) # comment out these two lines
y <- scale(y) # to reproduce your error
z <- rnorm(20)
t. <- interp(x,y,z)
t.df <- data.frame(t.)
gt <- data.frame( expand.grid(X1=t.$x,
X2=t.$y),
z=c(t.$z),
value=cut(c(t.$z),
breaks=seq(min(z),max(z),0.25)))
p <- ggplot(gt) +
geom_tile(aes(X1,X2,fill=value)) +
geom_contour(aes(x=X1,y=X2,z=z), colour="black")
p
在另一个问题中,在重新缩放之前还针对labeling the axes with the correct values of the original data描述了解决方案。目前仅适用于ggplot
。