[R] r-plot
Richard.Cotton at hsl.gov.uk
Richard.Cotton at hsl.gov.uk
Wed May 27 13:55:38 CEST 2009
> I want to make a simple plot, here is my code:
http://gist.github.com/118550
> Unfortunately, the annotation of both the x- and y-axis are not correct,
as
> you can see in the following picture:
> http://www.nabble.com/file/p23739356/plot.png
> I am not an expert of R, so maybe someone can point me to the solution
of
> this problem, i.e. both of the axes should start and end at the min /
max
> values of the two vectors.
>From the help page on par:
'xaxs' The style of axis interval calculation to be used for the
x-axis. Possible values are '"r"', '"i"', '"e"', '"s"',
'"d"'. The styles are generally controlled by the range of
data or 'xlim', if given. Style '"r"' (regular) first extends
the data range by 4 percent at each end and then finds an
axis with pretty labels that fits within the extended range.
Style '"i"' (internal) just finds an axis with pretty labels
that fits within the original data range.
You've explicitly set xaxs="r", when you really want xaxs="i". You can
also explicitly set the axis limits using xlim/ylim parameters in the call
to plot.
Compare these examples:
#Ex 1
plot(1:10) #implicitly uses par(xaxs="r", yaxs="r") unless you've
changed something
#Ex 2
oldpar <- par(xaxs="i", yaxs="i")
plot(1:10)
par(oldpar)
#Ex 3
plot(1:10, xlim=c(-5, 15), ylim=c(-100, 100))
Regards,
Richie.
Mathematical Sciences Unit
HSL
------------------------------------------------------------------------
ATTENTION:
This message contains privileged and confidential inform...{{dropped:20}}
More information about the R-help
mailing list