Shane

I ran your code with debugging and found this for minor ticks

[1]> minor.ticks
  [1] 1.000000 1.301030 1.477121 1.602060 1.698970 1.778151 1.845098 
1.903090 1.954243 3.000000 3.301030
[12] 3.477121 3.602060 3.698970 3.778151 3.845098 3.903090 3.954243 
5.000000 5.301030 5.477121 5.602060
[23] 5.698970 5.778151 5.845098 5.903090 5.954243 7.000000 7.301030 
7.477121 7.602060 7.698970 7.778151
[34] 7.845098 7.903090 7.954243
Note how they go from 1-2, then 3-4, 5-6, etc skipping every other decade.

Check the lines that produce minor.ticks

David Stevens

On 5/7/2014 10:32 AM, Shane Carey wrote:
> Hey,
>
> Im using the function below to create minor tick marks on log scale. It
> only plots every second marker, i.e. 10^0, 10^2 and so on. How do I get it
> to plot at every interval? Thanks
>
> minor.ticks.axis <- function(ax,n,t.ratio=0.5,mn,mx,...){
>
>    lims <- par("usr")
>    if(ax %in%c(1,3)) lims <- lims[1:2] else lims[3:4]
>
>    major.ticks <- pretty(lims,n=5)
>    if(missing(mn)) mn <- min(major.ticks)
>    if(missing(mx)) mx <- max(major.ticks)
>
>    major.ticks <- major.ticks[major.ticks >= mn & major.ticks <= mx]
>
>    labels <- sapply(major.ticks,function(i)
>              as.expression(bquote(10^ .(i)))
>            )
>    axis(ax,at=major.ticks,labels=labels,...)
>
>    n <- n+2
>    minors <- log10(pretty(10^major.ticks[1:2],n))-major.ticks[1]
>    minors <- minors[-c(1,n)]
>
>    minor.ticks = c(outer(minors,major.ticks,`+`))
>    minor.ticks <- minor.ticks[minor.ticks > mn & minor.ticks < mx]
>
>
>    axis(ax,at=minor.ticks,tcl=par("tcl")*t.ratio,labels=FALSE)}
>
> x <- 10^(0:8)
> y <- 1:9
> plot(log10(x),y,xaxt="n",xlab="x",xlim=c(0,9))
> minor.ticks.axis(1,9,mn=0,mx=8)
>
>
> Thanks
>
>

-- 
David K Stevens, P.E., Ph.D.
Professor and Head, Environmental Engineering
Civil and Environmental Engineering
Utah Water Research Laboratory
8200 Old Main Hill
Logan, UT  84322-8200
435 797 3229 - voice
435 797 1363 - fax
david.stev...@usu.edu



        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to