log probability plot in R?

后端 未结 2 1935
甜味超标
甜味超标 2021-01-06 15:11

Does anyone know how to create log probability plot like this one in R where the x-axis is probability and y-axis is in log-scale. I read and downloaded the package heR.Misc

2条回答
  •  孤街浪徒
    2021-01-06 15:53

    #create log probablity plot
    #MPM 131201
    #Make some dummy data
    set.seed(21)
    Dt<-as.data.frame(rlnorm(625, log(10), log(2.5)))
    names(Dt)<-"Au_ppm"
    
    #Create probablity scale lines and associated labels - 
    PrbGrd <- qnorm(c(0.001,0.01, 0.05, 0.10,0.20,0.30,0.40, 0.50, 0.60, 0.70,0.80,0.90,0.95,0.99,0.999))
    PrbGrdL<-c("0.1","1","5","10","20","30","40","50","60","70","80","90","95","99","99.9")
    
    #create some value grid lines then convert to logs
    ValGrd<-c(seq(0.001,0.01,0.001),seq(0.01,0.1,0.01),seq(0.1,1,0.1),seq(1,10,1),seq(10,100,10))
    ValGrd<-log10(ValGrd)
    
    #load up lattice packages - latticeExtra for nice log scale
    require(lattice)
    require(latticeExtra)
    
    #Use qqmath to make the plot (note lattice does not work for weighted data - shame about that)
    
    qqmath(~ Au_ppm, 
            data= Dt,
                distribution = function(p) qnorm(p),
            main = "Normal probablity / log (base 10) plot",
            pch=20,
            cex=0.5,
            xlab="Normal distribution scale (%)",
            scales=list(y=list(log=10,alternating=1),x = list(at = PrbGrd, labels = PrbGrdL, cex = 0.8)),
            yscale.components=yscale.components.log10ticks,
            panel=function(x,...){
                panel.abline(v=PrbGrd ,col="grey",lty=3)
                panel.abline(h=ValGrd,col="grey",lty=3)
                panel.qqmath(x,distribution=qnorm)
            }
    
        )
    

提交回复
热议问题