我正在尝试从格子包中制作一个水平图(也显示轮廓线)。我有几个问题(如下所述)。
我的数据: https ://www.dropbox.com/s/ht55g0qlkiou2x2/growth.matrix.stackoverflow.xlsx
require(lattice)
require(latticeExtra)
require(xlsx)
#matrix to be plotted
growth.matrix<-as.matrix(read.xlsx("C:/Users/eckmannm/Dropbox/growth.matrix.stackoverflow.xlsx",sheetName="p4.pct",colIndex=2:8,startRow=3,endRow=15,header=FALSE))
#column values
TempRange<-as.numeric(c(0, 2, 4, 6, 8, 10, 12))
#row values
MeanTemp<-as.numeric(c(6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18))
#x and y axis labels
x.range<-as.numeric(c(6, 8, 10, 12, 14, 16, 18))
#color ramp
col.l <- colorRampPalette(c('red', 'orange', 'yellow', 'green', 'cyan', 'blue'))
colorplot<-
levelplot(
growth.matrix,
row.values=(MeanTemp),
column.values=(TempRange),
col.regions=col.l,
at=seq(from=0,to=1.01,length=100),
lattice.options=list(key=list(cex=4)),
panel = panel.2dsmoother,
scales=list((x=list(labels=MeanTemp)), y=list(labels=TempRange)),
colorkey=list(at=as.numeric(factor(c(seq(from=0, to=1, by=.20)))),
labels=as.character(c( "0", "20%", "40%", "60%", "80%", "100%")),
col=(col.l)))
contourplot<-
contourplot(
growth.matrix,
row.values=MeanTemp,
column.values=TempRange,
at=seq(from=0, to=1.01, by=.2),
panel=panel.2dsmoother,
label.style=("flat"),
lwd=2,
labels=(list(cex=1.5,labels=(c("0", "20%", "40%", "60%", "80%", "100%")))))
(final.plot= (colorplot + contourplot))
>> dput(head(growth.matrix))
structure(c(0.117236699239957, NA, 0.416693811074919, NA, 0.776134455117953,
NA, NA, 0.263952225841477, NA, 0.582491856677524, NA, 0.855917480998914,
NA, NA, 0.423344191096634, NA, 0.6792888165038, NA, NA, NA, NA,
0.5164223669924, NA, 0.698561346362649, NA, NA, NA, NA, 0.534989142236699,
NA, NA, NA, NA, NA, NA, 0.507193268186754, NA, NA, NA, NA, NA,
NA), .Dim = 6:7, .Dimnames = list(NULL, c("X2", "X3", "X4", "X5",
"X6", "X7", "X8")))
1)我真的很想删除彩色区域边缘的垂直白色边框(在轴标签和图表之间)。
2)我希望图例有离散标签,断点与颜色不同
3)由于某种原因,等高线标签被绘制在图表之外???
任何帮助将不胜感激!提前致谢。