如何创建一个内部有网格的圆圈并在 R 中标记已占用的单元格?

How do I create a circle with a grid inside and mark occupied cells in R?

我如何创建一个内部有网格的圆,然后填充基于 X,Y 坐标系占用的单元格。

我的圈子是这样的(数字是位置个数字):

我已经设置了我的 X,Y 系统,位置 1 为 -2,4.....

谢谢,

艾丽莎

plot(5*c(1,0,-1,0), 5*c(0,1,0,-1) ,col="transparent")  # set coordinate range
abline(h=-5:5); abline(v=-5:5)  # the grid
polygon(  4.3*sin(seq(0,2*pi,length=100)), 
          4.3*cos(seq(0,2*pi,length=100)) )  # the circle
abline(h=0,v=0,lwd=2)  # the axes
 text( x=c( (1:4)-2.5,(1:6)-3.5, (1:8)-4.5, (1:8)-4.5, #offsets to center in cells
        (1:8)-4.5, (1:8)-4.5,  (1:6)-3.5, (1:4)-2.5 ),
   y=c( rep(4,4), rep(3,6), rep(2,8), rep(1,8), 
            rep(0,8), rep(-1,8), rep(-2,6), rep(-3,4) )-0.5, 
   labels=1:52)

抑制轴标签、轴刻度和删除 "overhang" 是向 plot函数调用。也许:

 ..., , xaxs="i", yaxs="i", xaxt="n", yaxt="n", ylab="", xlab="")  

这会产生这个: