

How can I label existing axis tick marks with a
simple function of axis value like 1/AxisValue?
It seems like this should be an operation where
I just use the formula.


On 04/01/2014 09:25 AM, Hurr wrote:
> How can I label existing axis tick marks with a
> simple function of axis value like 1/AxisValue?
> It seems like this should be an operation where
> I just use the formula.
>
Hi Hurr,
You can do this with boxed.labels (plotrix) if you know the position of
the axis labels. If not, maybe axis.mult (also plotrix) will help.
Jim
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


If you want to customize tick mark labels, use the axis() function.
Something along the lines of
plot(x,y, xaxt='n')
xat < pretty(x)
axis(1, at=xat, labels=1/xat)
Don

Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L627
Livermore, CA 94550
9254231062
On 3/31/14 3:25 PM, "Hurr" < [hidden email]> wrote:
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Don suggested something like this:
h=c(1,2,3,4,5,6,7,8,9)
v=c(9,8,7,6,5,4,3,2,1)
plot(h,v,xaxt='n')
xat=pretty(h)
axis(1,at=xat,labels=1/xat)
But it puts the tick marks at the dataxlocations.
If the tick locations are not automatic or
automatically separate from the data locations, then
I want to tell it where to put them using
a separate indicator. I am not familiar enough with
R to find the answer.
But if it would work, it would be valuable.


On 04/09/2014 02:06 AM, Hurr wrote:
> Don suggested something like this:
> h=c(1,2,3,4,5,6,7,8,9)
> v=c(9,8,7,6,5,4,3,2,1)
> plot(h,v,xaxt='n')
> xat=pretty(h)
> axis(1,at=xat,labels=1/xat)
> But it puts the tick marks at the dataxlocations.
> If the tick locations are not automatic or
> automatically separate from the data locations, then
> I want to tell it where to put them using
> a separate indicator. I am not familiar enough with
> R to find the answer.
> But if it would work, it would be valuable.
>
>
Hi Hurr,
If you want to use pretty:
pretty(1:9)
[1] 0 2 4 6 8 10
you don't necessarily get axis ticks at the same locations as the data
points. Maybe you want to specify your own axis ticks and use those:
axis_ticks<c(1,4,7,10)
axis(1,at=axis_ticks,labels=1/axis_ticks)
but that seems too obvious. Could you supply an example of what you want
to do?
Jim
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


This still puts tick marks at data points:
h=c(1,2,3,4,5,6,7,8,9)
v=c(9,8,7,6,5,4,3,2,1)
plot(h,v,xaxt='n')
x<c(1.6,2.6,6.6,9.6,12.9)
axis_labels<1/pretty(x)
axis(1,at=pretty(x),labels=axis_labels)
How do I get the axis to approx 13 ?


On 04/09/2014 01:12 PM, Hurr wrote:
>
> This still puts tick marks at data points:
> h=c(1,2,3,4,5,6,7,8,9)
> v=c(9,8,7,6,5,4,3,2,1)
> plot(h,v,xaxt='n')
> x<c(1.6,2.6,6.6,9.6,12.9)
> axis_labels<1/pretty(x)
> axis(1,at=pretty(x),labels=axis_labels)
> How do I get the axis to approx 13 ?
>
>
plot(x,xaxt="n",xlim=c(1,13))
Jim
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Thanks Jim, Labels for the following are at 0,2,4,6,8,10,12, not data, good.
and omitted where lack of room.
h=c(1.2,2.4,3.1,4.7,5.3,6.2,7.6,8.8,9.7)
v=c(9,8,7,6,5,4,3,2,1)
plot(h,v,xaxt='n',xlim=c(1,13))
x<c(1.6,2.6,6.6,9.6,12.9)
axis_labels<1/pretty(x)
axis(1,at=pretty(x),labels=axis_labels)
Suppose I really did want more control, like where and what exactly


On 04/09/2014 06:17 PM, Hurr wrote:
> Thanks Jim, Labels for the following are at 0,2,4,6,8,10,12, not data, good.
> and omitted where lack of room.
>
> h=c(1.2,2.4,3.1,4.7,5.3,6.2,7.6,8.8,9.7)
> v=c(9,8,7,6,5,4,3,2,1)
> plot(h,v,xaxt='n',xlim=c(1,13))
> x<c(1.6,2.6,6.6,9.6,12.9)
> axis_labels<1/pretty(x)
> axis(1,at=pretty(x),labels=axis_labels)
>
> Suppose I really did want more control, like where and what exactly
>
If you want to specify the exact values of the ticks for the "at"
argument, just remember to extend the x axis on the initial plot to
include all x values. If you want to get the missing labels, look at the
staxlab function in the plotrix package.
Jim
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


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 numberunit 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.


On Apr 9, 2014, at 6:17 PM, Hurr 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 numberunit 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.
It appears that this question has already been answered by Jim Lemon multiple ways. Have you tried his code? Have you followed the various links from the help page of `plot`? Have you constructed a test case and tried to solve this yourself? (He is a much more patient person than I am, but I'm sure he has some minimal expectation of the level of effort he expects from his correspondents.)
PLEASE (read more thoroughly?): (the material at the bottom of every regularly posted item on the list but not seen by Nabble users.)
PLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.

David Winsemius
Alameda, CA, USA
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Yes, the initial question is answered and the code works.
I suppose that I should not have added more to it.
I should have posted a new topic.
Sorry that I am not at all an R user.
Just trying to determine if I want to use it.
I just read your link.
Sorry to be more stupid than you expect.
I did notice that it said that rudeness is not acceptable.
None of the other helpers were rude.


You're on the right track, I think.
Try this example:
plot(21:30, xaxt='n')
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
?par
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 prewrite 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:
plot(21:30, xlab='Units')
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:
plot(1:10, 21:30)

Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L627
Livermore, CA 94550
9254231062
On 4/9/14 6:17 PM, "Hurr" < [hidden email]> wrote:
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.

