[R] Bar Plot Bars "Bleed" off Plotting Area

David Winsemius dwinsemius at comcast.net
Thu Jul 22 21:06:28 CEST 2010


On Jul 22, 2010, at 2:13 PM, Gregory Gilbert wrote:

> R Community,
>
> I have a stupid little barplot I am trying to construct (Windows XP,  
> R.11.1,
> 32-bit). Whenever I run it my bars run below the horizontal axis.  
> Can anyone
> (1) reproduce this and (2) offer a solution?

I'm not sure I should be offering this, as I consider this practice to  
be graphical prevarication and statistically unethical, but ...

?barplot

<read help page> .... so, add ", xpd=FALSE,"

-- 
David.

> Rather simplistic code follows
> (I am new to the community)> Thanks for your help!
>
> Greg Gilbert
>
> =================== CUT  HERE ===================
> options(repos="http://lib.stat.cmu.edu/R/CRAN/")
> install.packages("plotrix", dependencies=TRUE)
> update.packages()
> require(plotrix)
>
> ##        DATA
> ##    April September
> ##  1  46.6      50.0
> ##  2  43.3      53.3
>
> w <- read.csv("C:/Documents and
> Settings/vhachagilbeg/Desktop/pope/women.csv",
>               header=TRUE)
>
> attach(w)
> names(w)
> w
>
> barplot(as.matrix(w),
>        ylab="Percentage", ylim=c(40, 55), yaxt="n",
>        beside=TRUE, col=(rainbow(2)))
>
> text(x=1.5,y=48, "46.6%")
> text(x=2.5,y=44.3, "43.3%")
> text(x=4.5,y=51, "50.0%")
> text(x=5.5,y=54.3, "53.3%")
>
> box()
>
> axis(2, at=c(40, 45, 50, 55), labels=c("0", "45", "50", "55"))
>
> axis.break(2, 41)
>
> legend(1.5, 52.5, c("Mammograms", "Pap Smears"), bty="n",
>        fill=(rainbow(2)))
> ===================     END       ===================
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list