Re: [R] Alignment of lines within barplot bars

From: snowboarder101 <>
Date: Fri, 08 Apr 2011 13:25:30 -0700 (PDT)

Thanks for the reply. I looked at this before as I saw you had posted this, but this either doesn't work in my situation, or I am using it wrong.

Take the example in the function:

tmp <- barplot(1:4)
updateusr(tmp[1:2], 0:1, 1:2, 0:1)
lines(1:4, c(1,3,2,2), lwd=3, type='b',col='red')

But I want to use par(new=T) and plot(), so:

tmp <- barplot(1:4)
updateusr(tmp[1:2], 0:1, 1:2, 0:1)
plot(1:4, c(1,3,2,2), lwd=3, type='b',col='red')

The reason I do this is that the y-axis then corresponds to my plot() data. In my specific case, it's more like this:

tmp <- barplot(c(1.5,40),yaxt='n',names.arg=1:2,ylim=c(0,1.25*40)) axis(4)
updateusr(tmp[1:2], 1:2)

I want those points in the middle of the bars... but I want to keep the y-axis labels from the second plot. the par(new=T) probably wipes out the coordinates, so I'm not sure how use this?

Thanks Again.

View this message in context:
Sent from the R help mailing list archive at

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Sat 09 Apr 2011 - 03:49:43 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 18 Apr 2011 - 19:40:31 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive