R软件如何绘制气泡图?

 时间:2026-02-14 16:27:19

1、这里以R数据集trees为例。该数据集有三个变量Girth、Height、Volume。

我们以Height、Volume为x、y变量,对Girth变量进行处理,作为气泡半径大小。

attach(mtcars)

r=Girth/(2*pi) # 根据圆周长公式计算半径

  

R软件如何绘制气泡图?

2、设置各参数值,绘制图像。

N<-nrow(trees)#数据集的行数,即观察值的个数

symbols(Height,Volume,circles=r,inches=0.25,fg="grey",bg=rainbow(N),main="The symbols of trees ,circles=Girth/(2*pi)",xlab="Height",ylab="Volume")

text(Height,Volume,1:N) #为每个气泡添加标签

detach(trees)

R软件如何绘制气泡图?

3、绘制方格图,可以将circles=r替换成squares=r。

symbols(Height,Volume,squares=r,inches=0.25,fg="grey",bg=rainbow(N),main="The symbols of trees ,squares=Girth/(2*pi)",xlab="Height",ylab="Volume")

text(Height,Volume,1:N) #为每个气泡添加标签

R软件如何绘制气泡图?

  • python怎么打开 python怎么样
  • 《春天的故事》歌词
  • 如何创办一家自己的公司
  • 2021跨境电商行业哪些产品好卖?
  • 红烧鹅蛋酱骨头
  • 热门搜索
    mouth什么意思 什么是避孕套 四大发明都有什么 乐此不疲是什么意思 墓志铭是什么意思 坏账准备属于什么科目 izzue是什么牌子 cpu核数是什么意思 脖子酸痛是什么原因 cable是什么意思