Re: [R] barchart but with boxes

From: Daisy Englert Duursma <daisy.duursma_at_gmail.com>
Date: Tue, 08 Jun 2010 12:00:47 +1000

Thanks to all,

I did eventually come up with a solution which involved sub-setting the data first into categories, making an empty plot, and then plotting rectangles. I really like the ggplot2 and I will use that next time.

My ugly script is below

Thanks,
Daisy

plot(1, xlim=c(5,45),ylim=c(0,10),xlab="Year",ylab="+/- 1 \u03c3 Mean Patch Size (ha)",axes=F,type="n")

		title(main = list("Patch Size Agreement", cex=1.4))
		axis(2)
		box()
		mtext(c(2010,2030,2050,2070),side=1,line = 1, at=c(10,20,30,40))
		position<-seq(10, 40, length.out=4 )
		xlef<-position-2.5
		xrig <-position+2.5
		
		for(i in 1:nrow(sub00)){
			min_y<-sub00$minsd_ha[i]
			max_y<-sub00$maxsd_ha[i]
			xleft<-xlef[1]
			xrigh<-xrig[1]
			rect(xleft, min_y, xrigh, max_y,border = NA,col=rgb(0, 0, 0, alpha=0.03))
		}
		
for(i in 1:nrow(sub01)){
			min_y<-sub01$minsd_ha[i]
			max_y<-sub01$maxsd_ha[i]
			xleft<-xlef[2]
			xrigh<-xrig[2]
			rect(xleft, min_y, xrigh, max_y,border = NA,col=rgb(0, 0, 0, alpha=0.03))

}
for(i in 1:nrow(sub02)){ min_y<-sub02$minsd_ha[i] max_y<-sub02$maxsd_ha[i] xleft<-xlef[3] xrigh<-xrig[3] rect(xleft, min_y, xrigh, max_y,border = NA,col=rgb(0, 0, 0, alpha=0.03))
}
for(i in 1:nrow(sub03)){ min_y<-sub03$minsd_ha[i] max_y<-sub03$maxsd_ha[i] xleft<-xlef[4] xrigh<-xrig[4] rect(xleft, min_y, xrigh, max_y,border = NA,col=rgb(0, 1, 0, alpha=0.03))
}
______________________________________________
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 Tue 08 Jun 2010 - 02:04:27 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 Tue 08 Jun 2010 - 04:10:28 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