[R] Plot documentation; Axis documentation
Tamas Papp
tpapp at axelero.hu
Fri Jun 4 19:43:56 CEST 2004
On Fri, Jun 04, 2004 at 12:01:25PM -0500, Glynn, Earl wrote:
> Why when I do a "help(plot)" do I not see anything about parameters
> such as xlim or ylim? As someone new to R, finding that xlim and ylim
> even existed wasn't all that easy. Even help.search("xlim") shows
> nothing once I know xlim exists.
Suppose you want to change the range of x adn y values (that is what
xlim and ylim does, but you don't know that yet). You type
?plot
and you see no parameter that is directly relevant. However, the help
page gives you a couple of directions to go from here: you can check
?par (mentioned in the very first lines) and see a plethora of
parameters.
You search for "axis" (type /axis in a Linux terminal, or use C-S in
Emacs/ESS), and soon you will find
'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
So you now know that you need something called "xlim" (and ylim,
though that is not mentioned explicitly), but find no further
information on this page. Therefore you should follow in another
direction from ?plot: the very next one (in See also) is plot.default,
which has
xlim: the x limits (min,max) of the plot.
ylim: the y limits of the plot.
Lo and behold.
> I'd like to change the default axes but "help(axis)" isn't that
> informative about changing the frequency of ticks on the axes.
How would you like to change them? This list won't be able to help
you unless you tell us.
> I hadn't a clue what the "1" and "2" meant here without reading
> additional documentation. And where is the "LETTERS" constant defined
> and what else is defined there?
?LETTERS has the answer.
> Are there no common R constants defined somewhere so the axes be defined
> symbolically? Perhaps AXIS_X = 1, AXIS_Y = 2 would be better than just
> "1" and "2":
>
> plot(1:4, rnorm(4), axes=FALSE)
> axis(AXIS_X, 1:4, LETTERS[1:4])
> axis(AXIS_Y)
>
> This would at least provide a clue about what is going on here.
It would also clutter the namespace. Feel free to put
AXIS_X <- 1
AXIS_Y <- 2
in your .Rprofile.
> Why is R such a graphics rich language and the documentation is so
> lacking in graphics examples? Why can't the documentation include
> graphics too so one can study code and graphics at the same time? How
> do I know the graphics I'm seeing is what it's supposed to look like?
Because the documentation is pretty much device independent, you can
read in interactively on a terminal, or make HTML of PDF output.
Graphics would complicate that. IMHO the idea is worth thinking
about, but it might involve a lot of work with little benefits.
If you want to see examples and the resulting figures side-by-side,
get one of the good books on R (MASS would be a good one, see the
homepage). I think that you can buy a lot of good books for the price
of Matlab.
> I'd rather do more in R than MatLab but I find the R documentation
> somewhat lacking. I prefer not to read the R source code to find the
> answers.
I have been using R for a while, but I never HAD to read the source
code of any function to find out anything. On the other hand, reading
the sources will teach you a lot about R, as the core functions were
written by very good programmers in R.
Best,
Tamas
--
Tamás K. Papp
E-mail: tpapp at axelero.hu
Please try to send only (latin-2) plain text, not HTML or other garbage.
More information about the R-help
mailing list