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

时间:2017-06-14 12:17:31

标签: r yaxis

我试图绘制错误的条形图,但我的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

1 个答案:

答案 0 :(得分:1)

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

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