[R] ggplot with geom_tile

Pelt van, Saskia (KNMI) saskia.van.pelt at knmi.nl
Fri Dec 9 11:33:10 CET 2011


Dear R-users,
 
I am trying to make a plot with ggplot-geom_tile(), but cannot remove some unwanted (white) lines through my plot. 
 
Below a reproducible example: 
 
#####
library(ggplot2)
tot=as.data.frame(rep(seq(-50,50,5),each=21))
names(tot)="precip"
temp=rep(seq(-5,5,0.5),21)
tot$temp=temp
 
disc=array(dim=c(21,21))  
  for(i in 1:21){
    for(y in 1:21){
temp<- rev(seq(10000+((i-1)*500),12000+((i-1)*500),100))
disc[i,y]=temp[y]
  }}
  
disc1=t(disc)
bla=as.vector(disc1)
tot$dis=bla
 
cols=c("darkred"," white"," darkblue")
 
p <- ggplot(tot, aes(x=temp, y=precip,group=dis))
p+geom_tile(aes(fill=dis)) + scale_fill_gradientn(colours=cols)
###
 
This creates the plot that I want, but with white horizontal and vertical lines that I do not need. I have tried different things, but have not found the solution. Can you help me with this problem?
 
Kind regards,
 
Saskia van Pelt



More information about the R-help mailing list