首页 > 解决方案 > 使用 text() 函数时如何在 r 中打印计算值

问题描述

嘿,我正在绘制散点图

plot(seq(1:n),x,xlab='Length of Vectors',ylab='Vectors',
type='p',col='black',pch=20,main='Scatter plot of X & Y vectors')

points(x,col='red',type='p',pch=1,cex=2)
points(y,type='p',col='black',pch=20)
points(y,type='p',pch=3,col='blue',cex=2)
text(which.max(x),max(x),'max of x: ',pos=1,cex=0.5)

像这样在我的观点之外,我想写一个文本说'x的最大值:max(x)<-x的实际最大值',但是由于我使用的是text()函数,我必须使用''来写下我的文字,但我无法弄清楚我应该如何将 x 的 max 的结果如上表所示。

标签: rtextscatter-plot

解决方案


推荐阅读