[R] Plot problems: xlim
Haynes, Maurice (NIH/NICHD) [E]
haynesm at cfr.nichd.nih.gov
Fri Dec 23 13:32:13 CET 2005
I believe Jim Lemon's solution requires his plotrix package.
National Institutes of Health
Child and Family Research Section
From: Jim Lemon [mailto:bitwrit at ozemail.com.au]
Sent: Friday, December 23, 2005 10:12 PM
To: Ronnie Babigumira
Cc: R Help
Subject: Re: [R] Plot problems: xlim
Ronnie Babigumira wrote:
> 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)
> 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.
For only one line, it is probably easiest to stick in an axis break and
label the line on the x axis. Notice that the position of the line is
arbitrarily set to be far enough beyond the end of the density curve to
allow room for the axis break.
This is probably a common enough problem for inclusion in the axis.break
R-help at stat.math.ethz.ch mailing list
PLEASE do read the posting guide!
More information about the R-help