uneven spacing on axis with R

后端 未结 3 958
夕颜
夕颜 2021-01-14 21:02

I have a problem in plotting uneven scale plot on x axis with R

Here is an example:

plot(1:100,1:100)

will give the equal tick spac

相关标签:
3条回答
  • 2021-01-14 21:04

    For a logarithmic axis, use:

    plot(x,y,log="x")  ## specifies which axis to put on log scale
    

    For determining how many "tick marks" to use, check

    par()$lab
    

    Default is 5,5,7. To put more x axis labels, do

    par(lab=c(10,5,7))
    

    And for y:

    par(lab=c(5,10,7))
    
    0 讨论(0)
  • 2021-01-14 21:09

    This is not an easy one-off task to complete. You'll actually need to transform to the scaled data and supply custom tick marked axes. Any reason you haven't considered simply logging the x-axis instead? (supplying the option plot(x, y, log='x') will do that).

    What I think you've described is this:

    xnew <- ifelse(x<10, x, x/10)
    plot(xnew, y, axes=FALSE, xlab='x')
    axis(1, at=c(0, 10, 20), labels=c(0, 10, 100))
    axis(2)
    box()
    
    0 讨论(0)
  • 2021-01-14 21:23

    You could log the x axis:

    x<-1:100
    y<-1:100
    plot(log(x,base=10),y,axes=F)
    axis(2)
    axis(1,at=0:2,labels=10^(0:2))
    

    enter image description here

    0 讨论(0)
提交回复
热议问题