我有一个条形图,我想在这个条形图中添加一个图,但是根据x轴的不同比例值,我不能正确地做它。我希望第一条横过第一条,第二条穿过第二条和第三条,最后一条穿过第四条和第五条。我怎么才能在R里做到呢?我编写了以下代码:
barplot(c(2.5, .5, .5, 3.5, 6), names.arg=c("0-1","1-2", "2-3", "3-4", "4-5"))
lines(c(1, 2, 3,4 ,5), c(3, .1, .1, 4, 6.5), lty=2, lwd=2)发布于 2014-03-12 00:00:32
理解你想要什么有点复杂..。我会尽力帮你做以下两件事:
bp = barplot(...)
并在调用lineslines(bp, y.data, ...)时使用它们bp = barplot(..., ylim=range(data)+c(-1,1) ) # to set the y-limits during the call to barplot
或者:
lines(..., xpd=T) # to allow drawing in the plot margin最后,下面显示了一个最小的工作示例:
data = c(2.5, .5, .5, 3.5, 6)
bp = barplot(data, names.arg=c("0-1","1-2", "2-3", "3-4", "4-5"),
ylim = range(data)+c(-1,1) )
lines(bp, c(3, .1, .1, 4, 6.5), lty=2, lwd=2)

https://stackoverflow.com/questions/22338709
复制相似问题