Par () pin and oma options in R

I had a problem using the par oma option to set the title as a graph when I set the graph size using pin . The oma header is the path up (it seems out of the oma range) when pin used; when the pin commented out (as shown below), the location of the oma header is visually appealing. I tried to change the sequence of options of par , thinking that you can change clothes for others, but no luck. The code is below. The keys are appreciated! Thanks Tom

 par(mfrow=c(1,2)) # 1X2 graphs par(oma=c(0,0,5,0)) # top has 5 lines of space par(mar=c(4,4,2,1)+.1) # margin lines #par(pin=c(1.9,1.9)) # plot areas for graphs # plot 1 plot(rnorm(n=20),col="olivedrab",pch=19,ylim=c(-2.0,2.0),xlim=c(0,20),ylab="",xlab="") mtext("Observation No.",side=1,line=3) mtext("Random variate",side=2,line=3) mtext("Olivedrab Plot",side=3,line=2,cex=1.5) # plot 2 plot(rnorm(n=20),col="olivedrab2",pch=19,ylim=c(-2.0,2.0),xlim=c(0,20),ylab="",xlab="") mtext("Observation No.",side=1,line=3) mtext("Random variate",side=2,line=3) mtext("Olivedrab Plot",side=3,line=2,cex=1.5) mtext("Army Olive Drab Plots",side=3,line=3,cex=2,outer=TRUE) # add outer label 
+4
source share
1 answer

You have not described what you want to see, only that the code creates what you do not like. Having guessed that you want to see mtext , create a "main name" that is further from the outer edge of the graphics device (closer to the graphs), I suggest you use a negative line number to place it. As the man page says, “line” indicates “starting at 0 counts” (although I could not find a description of where we should expect the zero line to be.)

 par(mfrow=c(1,2)) # 1X2 graphs par(oma=c(0,0,5,0)) # top has 5 lines of space par(mar=c(4,4,2,1)+.1) # margin lines par(pin=c(1.9,1.9)) # plot areas for graphs # plot 1 plot(rnorm(n=20),col="olivedrab",pch=19,ylim=c(-2.0,2.0),xlim=c(0,20),ylab="",xlab="") mtext("Observation No.",side=1,line=3) mtext("Random variate",side=2,line=3) mtext("Olivedrab Plot",side=3,line=2,cex=1.5) # plot 2 plot(rnorm(n=20),col="olivedrab2",pch=19,ylim=c(-2.0,2.0),xlim=c(0,20),ylab="",xlab="") mtext("Observation No.",side=1,line=3) mtext("Random variate",side=2,line=3) mtext("Olivedrab Plot",side=3,line=2,cex=1.5) mtext("Army Olive Drab Plots",side=3,line=-3,cex=2,outer=TRUE) 
+3
source

Source: https://habr.com/ru/post/1434078/


All Articles