格子パッケージを使用して「滑らかな」等高線図を作成しようとしていますが、行列の値の半分を「無視」する方法があるかどうか知りたいです。説明するのは少し難しいですが、うまくいけば私のコードがこの質問を明確にします。
私のデータへのリンク
https://www.dropbox.com/s/a1todt21f1wzkuk/data.matrix.xlsx
コード:
#load necessary packages
require(xlsx)
require(lattice)
require(latticeExtra)
#import data
my.data<-read.xlsx("C:/Users/eckmannm/dropbox/data.matrix.xlsx", sheetName="1",row.names=TRUE)
my.data.matrix<-as.matrix(my.data)
#make ranges for axis
Max.Depth.Values<-(c(1,2,4,6,8,10,12,14,16,18,20))
Trap.Depth.Values<-(c(1,2,4,6,8,10,12,14,16,18,20))
#specify color ramp
col.l <- colorRampPalette(c('red', 'orange', 'yellow', 'green', 'cyan', 'blue'))
#make lattice plot
(colorplot<-
levelplot(
my.data.matrix,
row.values=(Trap.Depth.Values),
column.values=(Max.Depth.Values),
col.regions=col.l,
at=seq(from=0,to=18,length=101),
lattice.options=list(key=list(cex=4)),
aspect = "fill",
xlim=c(1,20),
ylim=c(1,20),
panel = panel.2dsmoother,
ylab=list("Trap Depth (m)",cex=1.4),
xlab=list("Max Depth",cex=1.4),
main=list("CPUE of Redside Shiners at Different Depths",cex=1.6),
colorkey=list(at=seq(from=0, to=18, length=80),
labels=list(at=c(0,3,6,9,12,15,18),
labels=c("0","3", "6", "9","12", "15", "18")))))
コードpanel=panel.2dsmoother
を使用すると、平滑化された画像を作成できます (下の画像 1 を参照)。ただし、1 未満のすべての値を無視しようとしている (色を付けないでおく必要がある) ため、このグラフは完全に誤解を招きます。を使用しないpanel=panel.2dsmoother
と、より「正しい」画像が得られますが、値が少なすぎるため、非常にピクセル化されています (下の画像 2 を参照)。
何か提案はありますか、それとも可能ですか?