r barplot ylab 是水平的而不是垂直的

r barplot ylab is horizontal instead of vertical

我正在尝试为错误绘制条形图,但我的 ylab 是水平的,我想在图的左侧是垂直的。

errors=c(7.338711e-07,1.399190e-03,1.666794e-04,2.513632e-04,
       1.888479e-04,1.394840e-03,6.682082e-03,6.471887e-05,
       7.800729e-05,2.087988e-04,3.150596e-03,5.698861e-04,
       5.961718e-04,2.681394e-05,3.202360e-05,3.912834e-04,
       4.910918e-05,6.131810e-05,1.184472e-03,6.525520e-04,
       3.543068e-05,1.816346e-04,1.717658e-04,2.370331e-05,
       8.101786e-05,1.013240e-05,1.511531e-03,3.026940e-04,
       7.963667e-04,5.409863e-04)

ages=60:89

barplot(t(errors),horiz=TRUE,las=2,beside=TRUE,col='orange',xlab="error",ylab=ages)

感谢您的帮助

结果图是 enter image description here

您必须使用 names.arg 参数,而不是 ylab:

barplot(height = errors, 
        names.arg = ages, 
        col = 'orange', 
        xlab = 'error', 
        horiz = TRUE, 
        las = 2, 
        space = .2)