Re: [R] Alignment of lines within barplot bars

From: snowboarder101 <daniel.benjamin.frank_at_gmail.com>
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)
par(new=T)
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)
par(new=T)
updateusr(tmp[1:2], 1:2)
plot(1:2,c(0.01,0.02),xaxt='n',pch=16)

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: http://r.789695.n4.nabble.com/Alignment-of-lines-within-barplot-bars-tp2533115p3437369.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive