uneven spacing on axis with R

后端 未结 3 959
夕颜
夕颜 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: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()
    

提交回复
热议问题