高亮显示R中matplot轴上的点

高亮显示R中matplot轴上的点,r,plot,R,Plot,我试图在R matplot中突出显示x轴上的某些点,但在网上找不到任何添加此突出显示的内容 我当前的R代码如下所示: matplot(tafmc[,-5], type="l", lwd=2, xlab="Read Length", ylab= "Base frequency at each position", axes=F) axis(2) axis(side=1,at=1:12) legend(legend = colnames(tafmc)[-5],"topright",col=1:4,

我试图在R matplot中突出显示x轴上的某些点,但在网上找不到任何添加此突出显示的内容

我当前的R代码如下所示:

matplot(tafmc[,-5], type="l", lwd=2, xlab="Read Length", ylab= "Base frequency at each position", axes=F)
axis(2)
axis(side=1,at=1:12)
legend(legend = colnames(tafmc)[-5],"topright",col=1:4, lty=1:4, lwd=2) 
使用tafmc:

> tafmc
               A          C          G         T        other
 [1,] 0.07750099 0.07069229 0.05263019 0.7964281 2.748438e-03
 [2,] 0.33514177 0.18633073 0.24072018 0.2377887 1.863047e-05
 [3,] 0.29248243 0.24511224 0.20211045 0.2599584 3.365314e-04
 [4,] 0.28781535 0.21744510 0.22640813 0.2682291 1.023197e-04
 [5,] 0.38658168 0.18382597 0.18121268 0.2477646 6.151013e-04
 [6,] 0.30973779 0.19046315 0.22233131 0.2765137 9.539984e-04
 [7,] 0.28136595 0.20856398 0.23399280 0.2760773 0.000000e+00
 [8,] 0.27421037 0.21245036 0.23216199 0.2811773 0.000000e+00
 [9,] 0.26470528 0.22441881 0.22949251 0.2813834 0.000000e+00
[10,] 0.30831951 0.20324602 0.22462079 0.2638137 0.000000e+00
[11,] 0.28210999 0.20171182 0.24064536 0.2755328 0.000000e+00
[12,] 0.28901716 0.20485948 0.23162141 0.2745020 0.000000e+00
当前的绘图如下所示:

我想要这样的东西(在本例中,突出显示X轴上的点1和点10):


有没有一种简单的方法可以做到这一点?或者我是否需要切换到ggplot2以获得等效内容。

您可以使用
rect

rect(c(0.7,9.7), c(0,0), c(1.3,10.3), c(1,1), col="#DD666666", border=NA)