stephane helleringer
2007-Apr-07 01:32 UTC
[R] Setting where the x-axis crosses the y-axis
Hi all, my apologies for a probably very obvious question but i can't figure out if, on a bar plot, there is a simple way to have the x-axis cross the y-axis at 1, when the y-axis is on a log-scale? I want to draw a bar plot, and have some of the bars "drop" below 1 while starting from 1. Is this possible? I have been trying various things using barplot, barplot2 etc... without success. Thanks a lot for your help, stephane
Richard M. Heiberger
2007-Apr-07 03:50 UTC
[R] Setting where the x-axis crosses the y-axis
I think you are looking for this tmp <- abs(rnorm(100, s=8)) ltmp <- log(tmp) plot(ltmp, type="h", yaxt="n", main="what you want") exp(par("usr")[3:4]) par("yaxp")[1:2] logticks <- axTicks(2, axp=c(10^c(-1,3),3), log=TRUE) axis(2, at=log(logticks), labels=logticks) plot(tmp, type="h", log="y", main="standard")
Hi Stephane, Drawing a bar plot with log axes is a really bad idea. The whole point of a bar is that you are judging the area between the top of the bar and the y-axis. If you use a log scaled axis the distance to y=0 is Inf, and your plot isn't really meaningul. You might want to consider using a dot plot instead. See http://www.b-eye-network.com/view/index.php?cid=2468&fc=0&frss=1&uafor a good discussion of the issues. Hadley On 4/6/07, stephane helleringer <hellerin at ssc.upenn.edu> wrote:> Hi all, > > my apologies for a probably very obvious question but i can't figure out if, on > a bar plot, there is a simple way to have the x-axis cross the y-axis at 1, > when the y-axis is on a log-scale? > I want to draw a bar plot, and have some of the bars "drop" below 1 while > starting from 1. Is this possible? > I have been trying various things using barplot, barplot2 etc... without > success. > Thanks a lot for your help, > > stephane > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >