Skip to content

infelicity with axTicks

4 messages · Duncan Murdoch, Spencer Graves, Martin Maechler

#
If the range fed to axTicks is too narrow, the output is only 2 points; 
shouldn't it degenerate to using "pretty" in such cases?


EXAMPLE:


ylims2 <- c(0.2, 0.8)
get_axp <- function(x) 10^c(ceiling(x[1]), floor(x[2]))
## mimic par("yaxs") == "i"
usr.i2 <- log10(ylims2)
(aT.i2 <- axTicks(side = 2, usr = usr.i2,
       axp = c(get_axp(usr.i2), n = 3), log = TRUE, nintLog = 5))
#[1] 0.2 0.5


Thanks, Spencer Graves
#
On 2025-06-22 8:15 a.m., Spencer Graves wrote:
I don't understand your point.  If I do

   plot(ylims2, ylims2, log="xy", yaxs="i", xaxs="r")

then both axes get ticks at the pretty(ylims2) locations.  If I set yaxp 
or xaxp to the  values you used, then I get c(0.2, 0.5), but why would I 
do that?

Duncan Murdoch
#
On 6/22/25 10:13, Duncan Murdoch wrote:
I want to plot one set of points and lines with 3 axes for both : for 
the cumulative hazard (H), the survival probability [S = exp(-H)], and 
the probability of failure (1-S).


I'm programming around it. This may be too rare an application to bother 
with.


Thanks for the reply. Spencer Graves


p.s. My specific application is my claim that the hazard rate for a 
nuclear war in the next year increases with the time since the last 
detonation in anger, namely Nagasaki 1945-08-09, for two reasons: (1) 
Nuclear proliferation and (2) managers of complex systems subject to 
rare but catastrophic failures "learn" from experience that they can 
"safely" take ever greater risks -- until a catastrophe proves them 
wrong. I estimate a range of subjective probabilities that each of 13 
major "nuclear close calls" like the 1962 Cuban missile crisis might 
have actually ended in a nuclear war, converted each range into a range 
for the cumulative hazard for each incident, then summed imputed means 
and variances for the computed hazard to get a total cum hazard. Then I 
converted that to the estimate of the Weibull scale parameter assuming 
the shape parameter is 1, 1.5, or 2:


https://docs.google.com/spreadsheets/d/18Iutk8BqmiBND06xbjCIP6DmxMKAliyxO9g88sL5e2Y/edit?usp=sharing


After I get my plot, I plan to post a description of this to Wikiveristy 
and then circulate that to leading experts and potential collaborators 
in getting something on this published.
4 days later
#
I've had a busy time the past week, so this just comes now,
(and as "top-reply", unusually for me, and this list in general..).

I've been the one adding  axTicks() to R  a long time ago,
and also  axisTicks();  these are related but really have
different goals and in particular,

-  axTicks () is in pkg {graphics}  as it applies to there only, whereas
- axisTicks() is in pkg {grDevices} as it would/should/could also apply to
              packages {grid}, {lattice} {ggplot2} etc

Their help page "title + description"s are

1)  axTicks --- Compute Axis Tickmark Locations

   Description:

     Compute pretty tickmark locations, the same way as R does
     internally.  This is only non-trivial when *log*
     coordinates are active.  By default, gives the ?at? values
     which ?axis(side)? would use.


2)  axisTicks --- Compute Pretty Axis Tick Scales

   Description:

     Compute pretty axis scales and tick mark locations, the
     same way as traditional R graphics do it.  This is
     interesting particularly for log scale axes.

Hence I guess you should really use axisTicks() rather than
axTicks() in your case.

However, even though we have tweaked both functions over time, we may not have considered all
edge cases, so would improve them where needed (and not too edgy / complicated).

Can you try to see if axisTicks() does solve your problem /
serve your purpose ?

Best regards,
Martin


--
Martin Maechler
ETH Zurich  and  R Core team