不均匀尺度内插间隙
Interpolating gaps in uneven scale
我有一个如下所示的数据框:
depth time temp
1 0 1 -1.620339e-02
2 10 1 -7.018468e-02
3 20 1 -4.392311e-02
4 30 1 -2.344012e-02
5 50 1 -1.817276e-02
6 75 1 -6.413543e-03
7 100 1 -6.547729e-02
...
320 700 20 2.285078e-02
深度变量不均匀,例如:0 10 20 30 50 75 100 125 150 200 250 300 400 500 600 700
我正在尝试创建一个图,其中 y = 深度,x = 时间,间隙由 temp
插值和着色。如果我这样做:
viz <- ggplot(temp_data, aes(time, depth, z = temp))
viz + geom_tile(aes(fill = temp)) + stat_contour()
它让我很接近,尽管由于深度尺度不均匀,它有很大的未绘制数据间隙。我想对间隙进行插值,但自从我使用 R 以来已经有一段时间了,我很难找到实现这一目标的最佳方法。
谢谢 - 非常感谢任何帮助或建议!
使用您的示例数据:
library(akima)
library(ggplot2)
interped <- with(temp_data, interp(time, depth, temp))
temp_data_interp <- with(interped,
data.frame(time=rep(x, length.out=length(z)), depth=rep(y, each=length(y)), temp=as.vector(z))
)
看看?interp
调整输出x和y值的数量。
如果不进行插值,您会得到以下图:
viz <- ggplot(temp_data, aes(time, depth, z = temp))
viz + geom_tile(aes(fill = temp)) + stat_contour()
插值后得到:
viz <- ggplot(temp_data_interp, aes(time, depth, z = temp))
viz + geom_tile(aes(fill = temp)) + stat_contour()
我有一个如下所示的数据框:
depth time temp
1 0 1 -1.620339e-02
2 10 1 -7.018468e-02
3 20 1 -4.392311e-02
4 30 1 -2.344012e-02
5 50 1 -1.817276e-02
6 75 1 -6.413543e-03
7 100 1 -6.547729e-02
...
320 700 20 2.285078e-02
深度变量不均匀,例如:0 10 20 30 50 75 100 125 150 200 250 300 400 500 600 700
我正在尝试创建一个图,其中 y = 深度,x = 时间,间隙由 temp
插值和着色。如果我这样做:
viz <- ggplot(temp_data, aes(time, depth, z = temp))
viz + geom_tile(aes(fill = temp)) + stat_contour()
它让我很接近,尽管由于深度尺度不均匀,它有很大的未绘制数据间隙。我想对间隙进行插值,但自从我使用 R 以来已经有一段时间了,我很难找到实现这一目标的最佳方法。
谢谢 - 非常感谢任何帮助或建议!
使用您的示例数据:
library(akima)
library(ggplot2)
interped <- with(temp_data, interp(time, depth, temp))
temp_data_interp <- with(interped,
data.frame(time=rep(x, length.out=length(z)), depth=rep(y, each=length(y)), temp=as.vector(z))
)
看看?interp
调整输出x和y值的数量。
如果不进行插值,您会得到以下图:
viz <- ggplot(temp_data, aes(time, depth, z = temp))
viz + geom_tile(aes(fill = temp)) + stat_contour()
插值后得到:
viz <- ggplot(temp_data_interp, aes(time, depth, z = temp))
viz + geom_tile(aes(fill = temp)) + stat_contour()