[R] labeling abscissa using a function of the plotted scale

Jim Lemon jim at bitwrit.com.au
Fri Oct 25 00:49:55 CEST 2013


On 10/25/2013 01:00 AM, Hurr wrote:
> Thanks Jim, maybe now I can start learning.
> Here is a run of my trying to learn:
>> xvalue<-c(5.2,1.3,9.7,2.8,8.1,4.7,6.6,7.4)
>> yvalue<-c(9,3,4,7,2,5,3,6)
>> plot(xvalue,yvalue)
>> axis(1,at=NULL,labels=1/xvalue,digits=5)
> Error in axis(1, at = NULL, labels = 1/xvalue, digits = 5) :
>    'labels' is supplied and not 'at'
> In addition: Warning message:
> In axis(1, at = NULL, labels = 1/xvalue, digits = 5) :
>    "digits" is not a graphical parameter
>>
> Why can't R automatically compute the spacing when I use the formula?
> How can I specify n-digits or width instead of round or nothing?
>
Hi Hurr,
Let's see, suppose I answered your message like this:

answer1<-NULL

You would be in the same position as the axis function. You have to tell 
the axis function where the labels are to be placed, or it can't place 
them there. Now for your second question. Suppose my answer was 
something like this:

answer2<-"wpsovmeksjhfhtieur" # language = Magungian

You might well respond that you don't understand Magungian. The argument 
"digits" doesn't tell the axis function anything useful. If you want 
labels with a certain number of digits, create them before you call the 
axis function:

mylabels<-round(1/xvalue,digits=5)

The round function understands Magungian.

Jim



More information about the R-help mailing list