Concentric Circles like a grid, centered at origin

前端 未结 2 1322
死守一世寂寞
死守一世寂寞 2021-01-05 11:44

I would like to include a sequence of concentric circles as a grid in a plot of points. The goal is to give the viewer an idea of which points in the plot have approximately

2条回答
  •  旧时难觅i
    2021-01-05 11:58

    How about this with ggplot2 and grid:

    require(ggplot2)
    require(grid)
    
    x<-(runif(100)-0.5)*4
    y<-(runif(100)-0.5)*4
    
    circ_rads<-seq(0.25,2,0.25)
    
    qplot(x,y)+
      lapply(circ_rads,FUN=function(x)annotation_custom(circleGrob(gp=gpar(fill="transparent",color="black")),-x,x,-x,x))+
      geom_text(aes(x=0,y=circ_rads+0.1,label=circ_rads)) + coord_fixed(ratio = 1) 
    

    enter image description here

提交回复
热议问题