[R] x-axis tick marks on log scale plot

Martin Maechler maechler at stat.math.ethz.ch
Fri May 20 11:21:41 CEST 2016

>>>>> Brian Smith <bsmith030465 at gmail.com>
>>>>>     on Thu, 19 May 2016 11:04:55 -0400 writes:

    > Thanks all !!  On Thu, May 19, 2016 at 9:55 AM, Ivan
    > Calandra <ivan.calandra at univ-reims.fr> wrote:

    >> Hi,
    >> You can do it by first plotting your values without the
    >> x-axis: plot(x,y,log="xy", xaxt="n")
    >> and then plotting the x-axis with ticks where you need to:
    >> axis(side=1, at=seq(2000,8000,1000))

Getting nicer looking axis ticks  for log-scale axes (and
traditional graphics) I have created the function
and utility function    pretty10exp(.)

and I also created standard R's  axTicks(.)  to help with these.

    if(!require("sfsmisc")) install.packages("sfsmisc")

    x <- lseq(1e-10, 0.1, length = 201)
    plot(x, pt(x, df=3), type = "l", xaxt = "n", log = "x")

gives the attached plot

-------------- next part --------------
A non-text attachment was scrubbed...
Name: eaxis-log-example.pdf
Type: application/pdf
Size: 5931 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20160520/1a82043a/attachment.pdf>

More information about the R-help mailing list