I set up a nice plot with a transparent superimposed scatterplot on a png image file. I want my plot window and my pdf output to be of the exact same size as my png- 962x745.
However, even after turning off axes, annotations and frames, R still leaves a border around the image.
This can be shown with an easy example: This plot shows two dots, which should be at the outermost ends of the plot. But they aren't:
plot(rbind(c(1,745),c(962,1)),bty ="n",axes=F,frame.plot=F, xaxt='n', ann=FALSE, yaxt='n', asp=745/962)
And together with the PDF device:
pdf(width=10.02,height=7.76)
par(mar=rep(0, 4),mai=rep(0, 4), xpd = NA)
plot(rbind(c(1,745),c(962,1)),bty ="n",axes=F,frame.plot=F, xaxt='n', ann=FALSE, yaxt='n', asp=745/962)
dev.off()
Try:
par(mar=rep(0, 4), xpd = NA)
plot(rbind(c(1,745),c(962,1)),bty ="n",axes=F,frame.plot=F, xaxt='n', ann=FALSE, yaxt='n', asp=745/962)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With