Hello everyone.
I am using ggplot and I need some help to merge these two plots into one.

plot_CR<-function(x,y,agentid,CRagent){
  library(ggplot2)
  
  agent<-CRagent[[agentid]] # To make following expression shorter
  ggplot((data.frame(x=CRX,y=CRY,sr=agent$sr)))+
  geom_point(aes(x,y,colour=cut(sr,c(0,-10,-20,-30,-40,-50,-60,-70,-80))))+
  geom_text(aes(x,y,color=cut(sr, c(0,-10,-20,-30,-40,-50,-60,-70,-80)), 
label=round(sr,3)),vjust=1,legend=FALSE)+labs(colour="CRagents[[i]]$sr")
}


plot_shad_f<-function(f){
  library(ggplot2)

  plotdata<-melt(f)
  names(plotdata)<-c('x','y','z')
  v<-ggplot(plotdata, aes(x, y, z = z))
  v + geom_tile(aes(fill=z)) 

}

The first plot puts points and texts below the points... in an area
while the second function in the same are fills the background using 
geom_tiles... Is it possible somehow to merge these two plots into one?

So far I have tried to merge the two functions as one but I fail as ggplot is 
not very clear to me what it needs.

   
  plotdata<-melt(f)
  names(plotdata)<-c('x','y','z')

  agent<-CRagent[[agentid]] # To make following expression shorter
  ggplot((data.frame(x=CRX,y=CRY,sr=agent$sr)))+
  geom_point(aes(x,y,colour=cut(sr,c(0,-10,-20,-30,-40,-50,-60,-70,-80))))+
  geom_text(aes(x,y,color=cut(sr, c(0,-10,-20,-30,-40,-50,-60,-70,-80)), 
label=round(sr,3)),vjust=1,legend=FALSE)+labs(colour="CRagents[[i]]$sr")
  geom_tile(aes(fill=z)) 
}

Could you please help me?

I would like to thank you in advance for your help

Regards
Alex



      
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to