Dear R users, The parameters xaxs and yaxs (function par, package graphics) seem not to work with the function hist (package graphics), even when the parameters xlim and ylim are defined. Is there any way to make yaxs="i" and xaxs="i" work properly with the function hist, mainly to produce histograms that "touch" the horizontal axis? The R documentation and the R mailing lists archive don't seem to be of help here. I am using R 2.3.1, running under Windows XP. ## Example: x <- rnorm(100) hist(x,breaks=seq(-4,4,0.5),ylim=c(0,40),yaxs="i", xlim=c(-4,4),xaxs="i") box() Thank you very much. Paulo Barata -------------------------------------------------------------- Paulo Barata Fundacao Oswaldo Cruz / Oswaldo Cruz Foundation Rua Leopoldo Bulhoes 1480 - 8A 21041-210 Rio de Janeiro - RJ Brasil E-mail: pbarata at infolink.com.br
Paulo Justiniano Ribeiro Jr
2006-Aug-08 02:06 UTC
[R] parameter yaxs / function hist (graphics)
Paulo One possibility is to draw the histogram without axes and then add them wherever you want. For instance with something along the lines: x <- rnorm(500) hist(x, axes=F) axis(1, line=-1) For more details: ?axis best P.J. Paulo Justiniano Ribeiro Jr LEG (Laborat?rio de Estat?stica e Geoinforma??o) Departamento de Estat?stica Universidade Federal do Paran? Caixa Postal 19.081 CEP 81.531-990 Curitiba, PR - Brasil Tel: (+55) 41 3361 3573 Fax: (+55) 41 3361 3141 e-mail: paulojus at est.ufpr.br http://www.est.ufpr.br/~paulojus On Mon, 7 Aug 2006, Paulo Barata wrote:> > Dear R users, > > The parameters xaxs and yaxs (function par, package graphics) > seem not to work with the function hist (package graphics), > even when the parameters xlim and ylim are defined. > > Is there any way to make yaxs="i" and xaxs="i" work properly > with the function hist, mainly to produce histograms that > "touch" the horizontal axis? The R documentation and the > R mailing lists archive don't seem to be of help here. > > I am using R 2.3.1, running under Windows XP. > > ## Example: > x <- rnorm(100) > hist(x,breaks=seq(-4,4,0.5),ylim=c(0,40),yaxs="i", > xlim=c(-4,4),xaxs="i") > box() > > Thank you very much. > > Paulo Barata > > -------------------------------------------------------------- > Paulo Barata > Fundacao Oswaldo Cruz / Oswaldo Cruz Foundation > Rua Leopoldo Bulhoes 1480 - 8A > 21041-210 Rio de Janeiro - RJ > Brasil > E-mail: pbarata at infolink.com.br > > ______________________________________________ > 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. > >