I am trying to make a simple illustration where a circle is plotted inside a square. I have used the rect()
function from the grid
package and the draw.circle()
function from the plotrix
package before so I thought this would be simple. But clearly I am missing something.
The following code seems to me like it should work:
require(plotrix)
require(grid)
plot(c(-1, 1), c(-1,1), type = "n")
rect( -.5, -.5, .5, .5)
draw.circle( 0, 0, .5 )
however I end up with the circle lapping out of the square in the vertical dimension like this:
What in the heck am I missing?
If you have a simpler way of plotting circles and squares, I'd love to know about it. But I'd also like to know why my method above does not work.
Thanks!