Adding custom tick marks on R plot

前端 未结 1 1632
感情败类
感情败类 2020-12-28 17:46

I\'m plotting a cdf of some data, and I\'ve added logarithmic scale on the \"x\" axis. The ticks spacing is exactly as I want it to be, but I\'d like to be able to add s

相关标签:
1条回答
  • 2020-12-28 18:07

    Considering the initial script, and the tips given by @BenBolker, I had to use:

    axis(side = 1, at = c([all the ticks you want]))
    

    in order to add the ticks in the graph. Here's the final result:

    # Cumulative Distribuition
    pdf("g1_3.pdf")
    
    plot(x = f$V2, y = cumsum(f$V1), log = "x", pch = 3,
         xlab = "Frequency", ylab = "P(X <= x)", axes = FALSE)
    
    ticks = c(1, 5, 10, 40, 150, 500, 1000)
    axis(side = 1, at = ticks)
    axis(side = 2)
    
    abline(h = seq(0, 1, 0.2), v = ticks, col = "lightgray", lty = 3)
    box()
    

    Final result to the graph I was trying to generate

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