带有interp R的filled.contour不覆盖我数据的整个区域

时间:2016-02-02 16:17:15

标签: r plot interpolation pca

我想在两个方面构建健身景观。这将采用地形图(带颜色)的形状。我有V1这是适合度值,数据集PC1中有PC2df5值。不幸的是,将filled.contourinterp一起使用,并未给出我的预期(参见图片)。

数据集:

df5=structure(list(V1 = c(0.535583210416683, 0.559996598363438, 0.446605278903053, 
0.675307731425936, 0.686685091981221, 0.726626361128919, 0.591518654833457, 
0.735708987771872, 0.584328495853679, 0.472473267159427, 0.559955416877159, 
0.65093831465458, 0.519075344410175, 0.617732901706271, 0.571305185804727, 
0.574834010521371, 0.473280188989535, 0.633489628155579, 0.478180029008305, 
0.543861646376236, 0.581633715103226, 0.597190744108704, 0.472461026802071, 
0.674251310674711, 0.653832151262236, 0.566590994731924, 0.47310582902301, 
0.64741170225752, 0.335956872982516, 0.610197890642666, 0.650937872340395, 
0.451019501235716, 0.69620199487762, 0.483672615657985, 0.646463594585488, 
0.549916725600253, 0.573706242864024, 0.486789839417478, 0.601195893448066, 
0.706928084429569, 0.580962433298967, 0.571951497141028, 0.49453590440671, 
0.538455554089932, 0.539832117434091, 0.612806533200573, 0.477780940941523, 
0.511973893911744, 0.405307099722093, 0.564321751420282), PC1 = c(-0.0820816112075804, 
0.288679786821525, -0.566833841325291, 0.339388785289801, 0.340152145652517, 
0.37272037141048, 0.369818408799889, 0.339478116577686, 0.281606404381885, 
0.293824282950724, -0.0774197290028415, 0.36286008666052, 0.373128936671052, 
0.345119354106124, 0.325514511942031, 0.263339335460136, 0.426877390878664, 
0.376328369296627, 0.328632428684531, 0.351858344271523, 0.385570193926696, 
0.340564252071443, 0.331524271539319, 0.352093120350566, 0.306020356732789, 
0.276080472128161, 0.27934446170352, 0.31137803013484, 0.374350072402797, 
0.347470873046814, 0.299477015135146, 0.24092028292779, 0.312644082452547, 
0.356203973507997, 0.374218409177796, 0.259623565571011, 0.306378475077542, 
0.314942445506132, 0.326067487496546, 0.318188537079511, 0.329842326669892, 
0.355149680898672, 0.281438227188359, 0.314859813467696, 0.304334993192228, 
0.282982558277037, 0.311288821334176, 0.326717994646236, 0.325392206008755, 
0.35395581423101), PC2 = c(-0.0726984154664933, -0.0579998435806135, 
-0.340782777981917, -0.00317441344007802, 0.00696616115160729, 
0.0197365185395031, -0.102664972456737, 0.0577075483133992, -0.031701029231375, 
-0.133017885554574, 0.0260894088410667, -0.0456145858775457, 
-0.164362022609647, -0.0594483394576116, -0.0810769011615437, 
-0.0232800179186733, -0.248481567550487, -0.0724403319539496, 
-0.158483011906846, -0.12610540322189, -0.124255258566613, -0.072824840785755, 
-0.165575323930921, -0.0150967682201028, 0.00644264561302165, 
-0.0414536788026684, -0.120053767116434, -0.00409220915760594, 
-0.319967472696812, -0.0678737493913382, 0.00968749456643262, 
-0.105412149093518, 0.0404174342623363, -0.17801128960014, -0.0592034478534605, 
-0.0405424965208479, -0.0623763085503774, -0.139740003357754, 
-0.0568806796041948, 0.0461740813183588, -0.0769413950530262, 
-0.106209115114044, -0.104541903430717, -0.0983463454431445, 
-0.0880610195070026, -0.00891872209056172, -0.143804225697214, 
-0.129828287831093, -0.215336812100236, -0.111392740039227)), .Names = c("V1", 
"PC1", "PC2"), row.names = c(NA, 50L), class = "data.frame")

健身景观代码:

require(akima)
resolution <- 0.1 
a <- interp(x=df5$PC1, y=df5$PC2, z=df5$V1, 
            xo=seq(min(df5$PC1),max(df5$PC1),by=resolution), 
            yo=seq(min(df5$PC2),max(df5$PC2),by=resolution), 
            duplicate="mean",
            linear = FALSE,extrap=TRUE)
filled.contour(a,
               xlim = c(-1,1.5), 
               ylim = c(-1,1.5),
               color.palette=heat.colors)
points(df5$PC1, df5$PC2,pch=c(21,22,23,24))

到目前为止,这就是我所拥有的。为什么右边的点不代表插值?我如何插入这些点?

That's all Folks!

0 个答案:

没有答案