使用带有多个添加点的 plot() 更改 R 中点的大小()

Change size of points in R using plot() with multiple added points()

数据可用here

我正在尝试生成下面的图(个人比例~年),除了我需要缩放所有点(resFresMimmF , 和 immM) 到每列的观测数(resFNresMNimmFNimmMN)。

我用来制作上面情节的代码如下:

library (plotrix)

plot(resF~year,data=data, type="b", col="black", xlab="Settlement year", ylab="Number of individuals", bty="l", pch=17, ylim=c(0,1))
ablineclip(v=1993, col="grey95", lwd=14, y1=0)
ablineclip(v=1998, col="grey95", lwd=14, y1=0)
ablineclip(v=2005, col="grey95", lwd=14, y1=0)
ablineclip(v=2010, col="grey95", lwd=14, y1=0)
ablineclip(v=2014, col="grey95", lwd=14, y1=0)
points(resF~year,data=data, col="black", type="b", pch=17)
points(resM~year,data=data, col="grey", type="b", pch=16)
points(immF~year,data=data, col="red", type="b", pch=17)
points(immM~year,data=data, col="orange", type="b", pch=16)
legend("topright", c("Resident females","Resident males", "Immigrant females", "Immigrant males"), col=c("black", "grey","red", "orange"), pch=c(17, 16, 17, 16), box.lty=0)

我正在绘制 resF,并为 resMimmFimmM 添加点。我想根据每列的观察次数来缩放点。例如,resF 需要根据 resFN 列中的观测值数量重新缩放,resM 缩放为 resMN 中的数字,等等

根据我所拥有的 read,我应该能够通过将 symbols(x=data$resFN, y=data$year, circles=sqrt(data$resFN/pi), inches=1/3, ann=F, bg="steelblue2", fg=NULL) 添加到我的 plot() 代码来重新缩放点。我遇到了问题,因为我将多个 points() 添加到原始 plot() 并且我还根据不同列中的值重新缩放。

关于如何完成此操作有什么建议吗?

例如,我不一定会推荐这种特定的缩放比例,但这为您提供了基本概念。我会按您认为合适的方式缩放分数。特别是,您需要决定它们是应该按类别单独缩放,还是在所有类别中按相同数量缩放。

plot(resF~year,data=data, type="b", col="black", xlab="Settlement year", 
     ylab="Number of individuals", bty="l", pch=17, ylim=c(0,1))
ablineclip(v=1993, col="grey95", lwd=14, y1=0)
ablineclip(v=1998, col="grey95", lwd=14, y1=0)
ablineclip(v=2005, col="grey95", lwd=14, y1=0)
ablineclip(v=2010, col="grey95", lwd=14, y1=0)
ablineclip(v=2014, col="grey95", lwd=14, y1=0)
points(resF~year,data=data, col="black", type="b", pch=17,cex = resFN / median(resFN))
points(resM~year,data=data, col="grey", type="b", pch=16,cex = resMN / median(resMN))
points(immF~year,data=data, col="red", type="b", pch=17,cex = immFN / median(immFN))
points(immM~year,data=data, col="orange", type="b", pch=16,cex = immMN / median(immMN))
legend("topright", c("Resident females","Resident males", "Immigrant females", "Immigrant males"), 
       col=c("black", "grey","red", "orange"), pch=c(17, 16, 17, 16), box.lty=0)