Drawing non-intersecting circles

后端 未结 1 1714
情话喂你
情话喂你 2020-12-10 11:27

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         


        
相关标签:
1条回答
  • 2020-12-10 12:13

    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 that asp = 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.

    0 讨论(0)
提交回复
热议问题