Labelling logarithmic scale display in R

前端 未结 3 764
孤城傲影
孤城傲影 2020-12-30 03:35

While plotting histogarm, scatterplots and other plots with axes scaled to logarithmic scale in R, how is it possible to use labels such as 10^-1 10^0 10^1 10^2 10^3 and so

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-30 03:50

    Here is a different way to draw this type of axis:

    plot(NA, xlim=c(0,10), ylim=c(1, 10^4), xlab="x", ylab="y", log="y", yaxt="n")
    at.y <- outer(1:9, 10^(0:4))
    lab.y <- ifelse(log10(at.y) %% 1 == 0, at.y, NA)
    axis(2, at=at.y, labels=lab.y, las=1)
    

    EDIT: This is also solved in latticeExtra with scale.components

提交回复
热议问题