Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

r language mtext not working with image.plot array

Tags:

r

I am using R to plot an array of plots using image.plot. Everything works well except that I cannot get mtext() to display a main title. Using very similar code for an array of plots using matplot() works fine.

The code I am using is given below.

op <- par(mfrow = c(2, 2))
par(mar=c(5, 4, 4, 2) + 0.1)
par(oma = c(0,0,2,1))
for (i in 2:nout){
  image.plot(r,th,t(u[i,,]),xlab="r",ylab=expression(paste(theta)),
    zlim=c(0.1,0.9), main=paste("t = ",t[i]),col=pal)
} 
mtext(side=3, outer=TRUE, cex=1.25, line=2,expression(
  paste("u(t,r,",theta, ")")))

Any help appreciated.

like image 616
Graham G Avatar asked Oct 15 '12 12:10

Graham G


1 Answers

I've run into some weird mtext() issues with image.plot() as well. One work around I've found is to use title() to "re-engage" the plot device, such that:

image.plot(x,y,z)
title("")
mtext("Title",side=3)

like image 188
nblarson Avatar answered Nov 03 '22 01:11

nblarson