Thanks a lot Ted!
I use R help but also cannot find how to expand the graph, i.e. sometimes
the top of it is cut for some reason. Maybe there are some limits imposed on
y axes, but cannot find it.

On Mon, Nov 30, 2009 at 12:27 PM, Ted Harding
<Ted.Harding@manchester.ac.uk>wrote:

> On 30-Nov-09 11:09:12, Trafim wrote:
> > Dear all,
> > I cannot find a function which would allow drawing hist and density
> > on the same graph.
> >
> > x <- seq(1,40,1)
> > y <- 2*x+1+5*rnorm(length(x))
> >
> > hist(y,freq = FALSE)
> > plot(density(y))
> >
> > thanks a lot for the help
>
> plot() initiates a completely new plot, and therefore erases what
> was there before. Use lines(), or points(), instead:
>
>  x <- seq(1,40,1)
>  y <- 2*x+1+5*rnorm(length(x))
>
>  hist(y,freq = FALSE)
>   lines(density(y))
>
> lines() *adds* extra elements (line segments) to an *existing* plot.
>
> See ?plot abd ?lines (and also ?points) for more explanation.
> Ted.
>
> --------------------------------------------------------------------
> E-Mail: (Ted Harding) <Ted.Harding@manchester.ac.uk>
> Fax-to-email: +44 (0)870 094 0861
> Date: 30-Nov-09                                       Time: 11:27:49
> ------------------------------ XFMail ------------------------------
>

	[[alternative HTML version deleted]]


