Re: [R] Histogram plot spacing
On 15.01.2013 12:35, Julie Collet wrote: Dear all, I'd like to remove the space between the x-axis and the 0 of the y-axis in the hist function. I saw the previous post https://stat.ethz.ch/pipermail/r-help/2012-September/324177.html suggesting adding the x-axis at position 0 (or the lowest value of y) after making the histogram. Unfortunately, it doesn't work in my case as I want to use it with a histogram with a ylim starting above 0, so that the x-axis ends up superposing the histogram bars. Any suggestion? For info, I've been using: hist(univariateCV$varcomp, ylim=c(10300,11100), xlim=c(-0.002,0.40), breaks=seq(0,1,0.004), axes=FALSE, main="", ylab="", xlab="",col='blue', xaxt="n") axis(1, at=seq(0,0.40,0.05), labels=seq(0,0.40,0.05), pos=10300) which gives the x axis superposed with the histogram bars. par(yaxs="i") hist(rnorm(100)) Uwe Ligges Many thanks Julie [[alternative HTML version deleted]] __ 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. __ 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.
[R] Histogram plot spacing
Dear all, I'd like to remove the space between the x-axis and the 0 of the y-axis in the hist function. I saw the previous post https://stat.ethz.ch/pipermail/r-help/2012-September/324177.html suggesting adding the x-axis at position 0 (or the lowest value of y) after making the histogram. Unfortunately, it doesn't work in my case as I want to use it with a histogram with a ylim starting above 0, so that the x-axis ends up superposing the histogram bars. Any suggestion? For info, I've been using: hist(univariateCV$varcomp, ylim=c(10300,11100), xlim=c(-0.002,0.40), breaks=seq(0,1,0.004), axes=FALSE, main="", ylab="", xlab="",col='blue', xaxt="n") axis(1, at=seq(0,0.40,0.05), labels=seq(0,0.40,0.05), pos=10300) which gives the x axis superposed with the histogram bars. Many thanks Julie [[alternative HTML version deleted]] __ 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.
Re: [R] histogram plot spacing problem
Hello, Try the following. x <- rnorm(100) hist(x, xaxt = "n") axis(1, at = pretty(x), pos = 0) Hope this helps, Rui Barradas Em 19-09-2012 18:51, firespot escreveu: Hi, So I plot a histogram using the built-in hist function: hist(rnorm(100), ...). Now the y-axis starts at its lower end at 0 (very sensible, of course) and that's where the baseline for the rectangles of the histogram is drawn, but the x-axis itself is offset a bit to the lower. I.e. there is some space between x-axis and null-point of y-axis / histogram lower end. What do I need to do to get rid of that space, so that x- and y-axis will intersect at y=0 ? Ideally the solution should be device- and screen-size independent. thanks! __ 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. __ 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.
[R] histogram plot spacing problem
Hi, So I plot a histogram using the built-in hist function: hist(rnorm(100), ...). Now the y-axis starts at its lower end at 0 (very sensible, of course) and that's where the baseline for the rectangles of the histogram is drawn, but the x-axis itself is offset a bit to the lower. I.e. there is some space between x-axis and null-point of y-axis / histogram lower end. What do I need to do to get rid of that space, so that x- and y-axis will intersect at y=0 ? Ideally the solution should be device- and screen-size independent. thanks! __ 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.