如何在图类型'h'中标记超出阈值的值

问题描述 投票:0回答:1

mtcars数据集和plot函数与参数type= 'h'一起使用,我只想用mtcars$wt >4标记观察值,但没有进行管理。我尝试过:

 plot(mtcars$wt,type = 'h',ylim = c(0,6))
    abline(h=4)
    text(mtcars$wt,row.names(mtcars[mtcars$wt >4,]),pos =3,col='blue',cex=0.6))

但是所有酒吧都被贴上标签:

enter image description here

我也尝试了Add labels to plot for specific values in R提供的解决方案,但没有设法使它起作用。

如果标签也可以以45度角也位于条形图的顶部,以避免重叠,那就太好了>>

使用参数类型为'h'的mtcars数据集和绘图函数,我只想将mtcars $ wt> 4标记为观察值,但没有进行管理。我试过了:plot(mtcars $ wt,type ='h',ylim = c(0,...

r plot label histogram
1个回答
0
投票

可能有几种解决方法。我试过了:

© www.soinside.com 2019 - 2024. All rights reserved.