I am trying to make a "smoothed" contour plot using the lattice package and curious if is any way to "ignore" half of the values in my matrix. A little difficult to explain but hopefully my code clarifies this question.
link to my data
https://www.dropbox.com/s/a1todt21f1wzkuk/data.matrix.xlsx
code:
#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")))))
With the code panel=panel.2dsmoother
, I am able to create a smoothed image (see image 1 below), but this graph is completely misleading because I am trying to ignore all the values that are less than 1 (they should be left uncolored). When I don't use panel=panel.2dsmoother
, I get a more "correct" image but it is very pixelated because I have too few values (see image 2 below).
Are there any suggestions or is this even possible?