【发布时间】:2015-09-08 02:39:37
【问题描述】:
library(season)
plot(CVD$yrmon, CVD$cvd, type = 'o',pch = 19,ylab = 'Number of CVD deaths per month',xlab = 'Time')
如果我想根据 x 值突出显示 1994-1998 年的图形区域,我该怎么做?
任何想法将不胜感激 谢谢。
【问题讨论】:
library(season)
plot(CVD$yrmon, CVD$cvd, type = 'o',pch = 19,ylab = 'Number of CVD deaths per month',xlab = 'Time')
如果我想根据 x 值突出显示 1994-1998 年的图形区域,我该怎么做?
任何想法将不胜感激 谢谢。
【问题讨论】:
或者您可以在感兴趣的区域上放置一个矩形:
rect(xleft=1994,xright = 1998,ybottom=range(CVD$cvd)[1],ytop=range(CVD$cvd)[2], density=10, col = "blue")
【讨论】:
rect 覆盖整个 y 范围 .. rect(xleft=1994,xright = 1998,ybottom=par("usr")[3], ytop=par("usr")[4], density=10, col = "blue") 。 see here
您可以将该范围内的点涂上另一种颜色,
plot(CVD$yrmon, CVD$cvd, type = 'o',pch = 19,ylab = 'Number of CVD deaths per month',xlab = 'Time')
points(cvd ~ yrmon, type="o", pch=19, col="red",
data=CVD[CVD$yrmon >= 1994 & CVD$yrmon <= 1998,])
【讨论】: