Re: [R] Plot problems: xlim

From: Jacques VESLOT <jacques.veslot_at_cirad.fr>
Date: Thu 22 Dec 2005 - 23:29:06 EST

Please give an example of your data.

set.seed(231)
morp <- rnorm(20)
range(morp)
[1] -2.311664 1.650254

You can plot 2 histograms, one of them with the extreme value:

par(mfrow=c(2,1))
hist(morp, breaks=10, freq=F)
lines(density(morp))
par(mfrow=c(1,2))
hist(morp, breaks=10, freq=F)
lines(density(morp))
hist(morp, breaks=seq(min(morp), max(morp), length=10), xlim=c(-3, 13), freq=F)
lines(density(morp))
abline(v=7.5, lty=3)

Ronnie Babigumira a écrit :

>Hi,
>Still fresh in R, tried to figure this out, now on my second day running with no luck (and a pile of hair on my desk) so
>I have thrown in the towel and would like to ask for some help.
>
>Here is what I am trying to do. I am trying to plot a distribution, I have 99 points, bound in the range
>
>xlim.min: -0.0173
>xlim.max: 0.02103
>
>However, I have a value outside this range (0.2454959) which I would like to add to the plot as a line and to do this I
>use abline(v=0.2454959)
>
>This is what I write
>
> >xlim = c(-0.02, 0.3)
> >denz <- density(morp)
> >plot.density(denz, xlim = xlim, ylim = c(0,70))
> >hist(morp, freq=F, add= T)
> >abline(v=0.2454959)
>
>Without any options, plot.density spreads out nicely, however, naturally, the line I want to add is not plotted since it
>is well outside the range automatically determined by plot.density hence the need to add xlim however this produces
>something I dont find aesthetically appealing. The plot is squeezed out into a very lean "bell" shape.
>
>So (finally) my question, how can i widen the spread of my plot and yet also be able to add my xline.
>
>Many thanks
>
>Ronnie
>
>______________________________________________
>R-help@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
>
>
>



R-help@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 Received on Thu Dec 22 23:36:34 2005

This archive was generated by hypermail 2.1.8 : Fri 23 Dec 2005 - 02:34:22 EST