无法在条形图中添加箭头

时间:2019-02-03 15:05:14

标签: r

我正在尝试将箭头(误差线)添加到简单的柱状图中。第一个起作用,而后两个起作用,即使错误消息的格式完全相同,它们也会带来大量错误消息!

secondtimes<-c(568.4667,604.2,585.8)
xabels<-c("1","2","3")
secondplot<-barplot(secondtimes,xlab = "Treatment",ylab = "Time taken / secs",ylim = c(0,800))
axis(1,at=secondplot,labels=xabels)  
arrows(0.7, 522.3074, 0.7, 614.6259, length=0.05, angle=90, code=3)
arrows(1.9, 496.4951, 1.9, 496.4951, length=0.05, angle=90, code=3)
arrows(3.1, 482,3277,3.1, 689.2723, length=0.05, angle=90, code=3)

箭头错误(1.9,496.4951,1.9,496.4951,长度= 0.5,角度= 90,:   无效的箭头规范 另外:警告消息: 1:在doTryCatch(return(expr),name,parentenv,handler)中:   零长度箭头的角度不确定,因此跳过了 2:在doTryCatch(return(expr),name,parentenv,handler)中:   零长度箭头的角度不确定,因此跳过了 3:在doTryCatch(return(expr),name,parentenv,handler)中:   零长度箭头的角度不确定,因此跳过了 4:在doTryCatch(return(expr),name,parentenv,handler)中:   零长箭头的角度不确定,因此被跳过

This is how the plot turns out

1 个答案:

答案 0 :(得分:1)

解决了...

secondtimes<-c(568.4667,604.2,585.8)
xabels<-c("1","2","3")
secondplot<-barplot(secondtimes,xlab = "Treatment",ylab = "Time taken / secs",ylim = c(0,800))
axis(1,at=secondplot,labels=xabels)  
arrows(0.7, 522.3074, 0.7, 614.6259, length=0.05, angle=90, code=3)
arrows(1.9, 496.4951, 1.9, 711.9049, length=0.05, angle=90, code=3)
arrows(3.1, 482.3277,3.1, 689.2723, length=0.05, angle=90, code=3)