【问题标题】:formatting the x-axis exponential plot in R as a^x?将 R 中的 x 轴指数图格式化为 a^x?
【发布时间】:2019-06-26 21:04:02
【问题描述】:

我在 R 中生成了这个图,x 轴上有一些奇怪的数字格式: enter image description here 我想在 x 轴上将格式 (ax) 中的数字设为 2^6、6^6、10^6。这将简化 x 轴以获取所有点的数据。请问您有什么建议吗?

这是我的代码:

data=read.csv("my_file.csv",row.names = 1)
plot(genes~Prot,cex=1.5,data, function(x) 10^x, xlab="Proteome 
size(codons)",ylim=c(0,30), ylab="Genes in pathway")
abline(lm(prot~genes,data),lty=2, lwd=3,col="black")

【问题讨论】:

    标签: r formatting axis exponent


    【解决方案1】:

    使用xaxt = 'n' 作为plot 的参数来关闭x 轴标签。然后使用Axis函数根据需要设置刻度线和标签。

    # Generating some data
    power <- seq(1, 6, length.out = 20) 
    Prot = 10^power
    genes <- runif(20, min = 5, max = 30)
    
    # plotting
    plot(x= Prot, y= genes, cex=1.5, xlab="Proteome size(codons)", ylab="Genes in pathway", xaxt = 'n', log = 'xy')
    Axis(at = c(2^6, 6^6, 10^6), side = 1, labels = c('2^6', '6^6', '10^6'), las = 1)
    

    【讨论】:

    • 非常感谢,这很有帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多