I\'m trying to plot two non-intersecting touching circles, but I think I\'m missing something quite basic...
jpeg(file=\"test.jpg\")
diam <- sqrt (2)
plot
Set the aspect ratio via asp
:
diam <- sqrt (2)
plot (c(-1,1), c(1,-1), xlim=c(-3,3), ylim=c(-3,3), asp=1)
symbols (c(-1,1), c(1,-1), circles=c(diam,diam), add=TRUE, inches=FALSE)
Updated to add Gavin Simpson's excellent insights from the comments and chat. My answer may be correct, but Gavin provides the very helpful reasons why asp=1
works and why it isn't the default behavior. Many thanks to him.
The default plotting device settings attempt to display the data without assuming anything about the scale of the relationship between the variables. To directly quote Gavin:
The reason
asp = 1
is not the default is thatasp = 1
doesn't make sense for data that do not share a common unit of measurement, such as height vs weight. Why should a change of 1m in height be represented as a change of 1kg in weight?
and
As a result, distance along the x axis bears no relationship to those on the y axis. As such, what is plotted is a transformation of real circles - they really are circles, just translated because the coordinate system you are plotting them into isn't appropriate.
A way to illustrate Gavin's points would be to plot the circles on the default device (not the jpeg device), then re-size the device. You can make the circles look all sorts of weird.