Hi Rainer M Krug <r.m.k...@gmail.com> napsal dne 07.10.2009 12:40:39:
> > On Wed, Oct 7, 2009 at 12:26 PM, Petr PIKAL <petr.pi...@precheza.cz> wrote: > Hi > > Rainer M Krug <r.m.k...@gmail.com> napsal dne 07.10.2009 12:09:21: > > > > <snip> > In the meantime, what about > > x <- rnorm(200) > hist(x, col = "blue", freq = TRUE) > ddd<-density(x) > lines(ddd$x, ddd$y*100, col = "red", lwd = 2) > > and then add suitable y axis. > > axis(4, at=pretty(ddd$y*100), labels=pretty(ddd$y), col=2) > > Yes - that definitely works. > > I usually use the following approach: determine the xlims in advance, and then > set them manually for each plot: > > x <- rnorm(200) > xlim <- trunc(range(x)) + c(-1, +1) > > hist(x, col = "blue", freq = TRUE, xlim=xlim) hhh <- hist(x, col = "blue", freq = TRUE) gives you object from which you can extract limits for plotting maybe better then from original data and you do not need to call > par(new=TRUE) Regards Petr > plot(density(x), xlim=xlim, ann=FALSE, axes=FALSE) > axis(4) > > But it is sometimes tricky to get the xlims for the plot. > > Regards > Petr > ______________________________________________ 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.