tags:

views:

52

answers:

1

I'm using the geom_tile to draw an imagemap and want to clear out the zero level for clarity.

#dummy data
set.seed(1)
tdata <- data.frame(cat1=rep(letters[1:3],4),cat2=sort(rep(LETTERS[1:4],3)),val=rpois(12,1.5))
tdata$val<-tdata$val/max(tdata$val)

I have found 2 ways to do this but both have their drawbacks:

1)

qplot(cat1,cat2,data=tdata,geom="tile",fill=val) + scale_fill_continuous(limits=c(.Machine$double.eps,1))

This has the drawback that the min value colour isn't printed in the scale.

2)

qplot(cat1,cat2,data=tdata,geom="tile",fill=val,alpha=ifelse(val,1,0))

This has the drawback that the alpha scale is plotted too. Wrapping the alpha argument in an I() causes it to fail.

Is there a way to do this without the drawbacks?

+2  A: 

You can subset your data.

qplot(..., data=subset(tdata, val > 0), ...) 
qplot(cat1,cat2,data=subset(tdata, val >0),geom="tile",fill=val)
Brandon Bertelsen
Of course, didn't think about that, thanks
James