Title going out of frame in plot canvas in R -
hi have 3 plots density bars on either axis have done way (here simpler form presented 3 ordinary plots other parts necessary required more complicated function have left off here ease of viewing)
scatterbar.norm <- function(x,y) { zones <- matrix(c(2,0,1,3), ncol=2, byrow=true) layout(zones, widths=c(5/7,2/7), heights=c(2/7,5/7)) title("my title", outer=true); par(mar=c(3,3,1,1),mgp=c(2,1,0)) plot(1:10, xlab="magnification", ylab="residue", col=2) par(mar=c(0,3,1,1)) plot(1:10, xlab="magnification", ylab="residue",col=3) par(mar=c(3,0,1,1)) plot(1:10, xlab="magnification", ylab="residue", col=4)} scatterbar.norm(2,3)
the problem : firstly the plot title "my title" part going out of canvas , how fix ?
thanks needed in advance.
you've instructed r plot title in outer margin, (at least in example) haven't set margin. following should work:
scatterbar.norm <- function(x, y) { zones <- matrix(c(2, 0, 1, 3), ncol=2, byrow=true) layout(zones, widths=c(5, 2), heights=c(2, 5)) par(mar=c(3, 3, 1, 1), mgp=c(2, 1, 0), oma=c(0, 0, 3, 0)) plot(1:10, xlab="magnification", ylab="residue", col=2) par(mar=c(0, 3, 1, 1)) plot(1:10, xlab="magnification", ylab="residue", col=3) par(mar=c(3, 0, 1, 1)) plot(1:10, xlab="magnification", ylab="residue", col=4) title("my title", outer=true) } plot.new() scatterbar.norm(2, 3)
Comments
Post a Comment