Hi all,

Quick question: What function can I use to draw a line in the margin of a plot? 
 segments() and lines() both stop at the margin.

In case the answer depends on exactly what I'm trying to do, see below.  I'm 
using R v. 2.8.1 on Windows XP.

Cheers,
Alan

I'm trying to make a horizontal barplot with a column of numbers on the right 
side.  I'd like to put a line between the column header and the numbers.  The 
following reconstructs the idea - just copy and paste it in:
aa <- 1:10
plot.mtx2<-cbind(aa,aa+1)
colnames(plot.mtx2)<-c("Male","Female")
lci2<- cbind(aa-1,aa)
uci2<- cbind(aa+1,aa+2)
par(mar=c(5,6,4,5))
cols <- c("grey79","grey41")
bplot2<-barplot(t(plot.mtx2),beside=TRUE,xlab="Malaria death rates per 100,000",
names.arg=paste("state",aa,sep=""),legend.text=F,las=1,xlim=c(0,13), horiz=T, 
col=cols,
main="Malaria death rates by state and sex")
legend(8,6,legend=c("Female","Male"),fill=cols[order(2:1)])
segments(y0=bplot2, y1=bplot2, x0=t(lci2), x1=t(uci2))
mtext(10*(aa+1),side=4,line=4,at=seq(3,3*length(aa),by=3)-0.35,padj=0.5,adj=1,las=1,cex=0.85)
mtext(10*aa,side=4,line=4,at=seq(2,3*length(aa)-1,by=3)-0.65,padj=0.5,adj=1,las=1,cex=0.85)
mtext("Estimated",side=4,line=3,at=3*length(aa)+2.75,padj=0.5,adj=0.5,las=1,cex=0.85)
mtext("Deaths",side=4,line=3,at=3*length(aa)+1.25,padj=0.5,adj=0.5,las=1,cex=0.85)

______________________________________________
R-help@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.

Reply via email to