Here is a good solution using only the R base and outputting to png. Please note that the device pnghas equal width and height by default .
png("magic_square.png")
par(mar=c(.5,.5,.5,.5))
plot(x=df$x,y=df$y,pch=as.character(df$val),
asp=1, xlim=c(0.5,3.5),ylim=c(0.5,3.5),xaxt="n",yaxt="n",xlab="",ylab="",
xaxs="i", yaxs="i", axes=F)
abline(v=0.5+(0:3),h=0.5+(0:3))
dev.off()
You can use cexin a call plotto increase the number.
And you can add circles as follows. Pay attention to the abline locations.
symbols(1.5,1.5,circles=1,add=TRUE)
, , points, .
symbols(1.5,1.5,circles=1,bg="white",add=TRUE)
text(x=1.5,y=1.5,labels="17",cex=3)
, , plot, symbols text .
