[R] hist, lines, rug
Prof Brian Ripley
ripley at stats.ox.ac.uk
Sat Jun 5 09:53:18 CEST 2004
On Fri, 4 Jun 2004, Kim Wong wrote:
> I'm trying to plot a historgram with a density plot superimposed:
>
> hist(x, seq(-1, 1, by = 0.1), prob = T, col = "blue")
> lines(density(x, bw = 0.1))
> rug(x)
>
> I don't want to add rug(x) but the histogram will not be plotted unless
> rug(x) is there. It does not work if the "hist" line alone is present.
> Can you help?
No, as
x <- runif(1000, -1, 1)
hist(x, seq(-1, 1, by = 0.1), prob = T, col = "blue")
lines(density(x, bw = 0.1))
works for me. Please give us a fully reproducible example (what is x?
what version of R? what graphics device? ...).
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list