[R] Label axis tick marks with a simple function of axis value
macqueen1 at llnl.gov
Sat Apr 12 00:05:27 CEST 2014
You're on the right track, I think.
Try this example:
labs <- paste(1:10,'units',sep='\n')
axis(1, at=1:10, labels=labs, mgp=c(3, 1.75, 0) )
Documentation for the mgp option is found in
and it's not something that I would expect someone new to R to find easily.
In my opinion, the philosophy of R is that a lot of basic tools are
provided, and from them the user is expected to customize and construct
precisely what they want. Although, many of the R packages available from
CRAN exist because someone wanted to pre-write some fancy options for
users to choose from.
Of course, since all the units are the same in my example, it might make
more sense to put the units in the axis label, such as:
Note a little "trick" in that in the above example that might be
unexpected. I didn't supply both x and y. When only one of them is
supplied, it is interpreted as being y values. Since there are 10 of them,
it is as if it were:
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
On 4/9/14 6:17 PM, "Hurr" <hill0093 at umn.edu> wrote:
>What we've covered so far is of great value.
>For a neater plot,
>the next step will be to learn how to put
>numbers with units at each tick mark.
>I suppose I can form the number-unit string myself in
>separate code and put the tickmark in a place that
>I calculate in separate code.
>But I need to learn the plotting code.
>View this message in context:
>Sent from the R help mailing list archive at Nabble.com.
>R-help at r-project.org mailing list
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.
More information about the R-help