John Fox
2022-Apr-10 21:50 UTC
[R] superscript of plot 2 x-mean(x) vs. (x-xmean)^2 has part of the superscript 2 cutoff.
Dear John, You can adjust par("mar"), e.g., oldpar <- par(mfrow=c(1,2),mfcol=c(1,2), mar=0.1+c(5, 5, 1, 1)) I hope this helps, John On 2022-04-10 5:40 p.m., Sorkin, John wrote:> x <- 0:100 > xsq <- x^2 > mydata1 <-data.frame(x=x,xsq=xsq) > > oldpar <- par(mfrow=c(1,2),mfcol=c(1,2)) > > # First plot. This plot is fine. > plot(x,xsq,xlab="",ylab="",cex=0.5) > title(,xlab="x",ylab=expression(x^2)) > abline(lm(xsq~x,data=mydata),col="red") > length(x) > length(xsq) > cor(x,xsq) > text(40, 8000, expression(Correlation == 0.97)) > > # Second Plot. Label of the y axis of this plot > # has the superscript 2 cut off. > xcentered <- x-mean(x) > xcenteredsq <- xcentered^2 > plot(xcentered,xcenteredsq,xlab="",ylab="",cex=0.5) > # Superscipt of the y axis is cut off. > title(xlab="x-mean(x)",ylab=expression((x-mean(x))^2)) > abline(lm(xcenteredsq~xcentered),col="red") > cor(xcentered,xcenteredsq) > text(0, 2000, expression(Correlation == 0.00))-- John Fox, Professor Emeritus McMaster University Hamilton, Ontario, Canada web: https://socialsciences.mcmaster.ca/jfox/