Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plot completely without borders

Tags:

plot

r

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()
like image 491
Inferrator Avatar asked Dec 05 '22 18:12

Inferrator


1 Answers

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)
like image 185
Tyler Rinker Avatar answered Jan 02 '23 04:01

Tyler Rinker