Categorical bubble plot for mapping studies

后端 未结 3 1721
有刺的猬
有刺的猬 2020-12-08 21:41

How to create a categorical bubble plot, using GNU R, similar to that used in systematic mapping studies (see below)?

3条回答
  •  伪装坚强ぢ
    2020-12-08 22:30

    Here is ggplot2 solution. First, added radius as new variable to your data frame.

    grid$radius <- sqrt( grid$count / pi )
    

    You should play around with size of the points and text labels inside the plot to perfect fit.

    library(ggplot2)
    ggplot(grid,aes(Var1,Var2))+
      geom_point(aes(size=radius*7.5),shape=21,fill="white")+
      geom_text(aes(label=count),size=4)+
      scale_size_identity()+
      theme(panel.grid.major=element_line(linetype=2,color="black"),
            axis.text.x=element_text(angle=90,hjust=1,vjust=0))
    

    enter image description here

提交回复
热议问题