1
这里是我的[R计划:R:?我如何使用R中的同一坐标系直观的对比绘制两个图形
#The code of the first picture
a<-c(278,410,37.9,100,300,71,195,51.05,59.4,145,900,718,220,130,220,138,
135,206,260,150,510,310,70,17,120,110,254.6,289.3,190)
b<-log10(a)
b.n<-length(b)
b.location<-mean(b)
b.var<-(b.n-1)/b.n*var(b)
b.scale<-sqrt(3*b.var)/pi
library(stats4)
ll.logis<-function(location=b.location,scale=b.scale){-sum(dlogis(b,location,scale,log=TRUE))}
fit.mle<-mle(ll.logis,method="Nelder-Mead")
fit.location<-coef(fit.mle)[1]
fit.scale<-coef(fit.mle)[2]
plot(b, rank(b)/length(b),pch=16,xlab="Lg toxicity
data(μg/L)",pch=16,xlab="Lg toxicity data(μg/L)",ylab="Cumulative probability",lwd=3,font.lab=2,font.axis=2)
f <- function(x) plogis(x, fit.location, fit.scale)
plot(f, add=TRUE, xlim=extendrange(b,f=0.5))
#The code of the second picture is
c<-c(1300,541,441,35,278,167,276,159,126,60.8,160,9740,3480,264.6,379,170,251.3,
155.84,187.01,2800,66.5,420,840,40,1380,469,260,50,370)
d<-log10(c)
d.n<-length(d)
d.location<-mean(d)
d.var<-(d.n-1)/d.n*var(d)
d.scale<-sqrt(3*d.var)/pi
library(stats4)
ll.logis<-function(location=d.location,scale=d.scale){-sum(dlogis(d,location,scale,log=TRUE))}
fit.mle<-mle(ll.logis,method="Nelder-Mead")
fit.location<-coef(fit.mle)[1]
fit.scale<-coef(fit.mle)[2]
plot(d, rank(d)/length(d),pch=25,col="blue",xlab="Lg toxicity data(μg/L)",ylab="Cumulative probability",lwd=3,font.lab=2,font.axis=2)
k <- function(c) plogis(c, fit.location, fit.scale)
plot(k, add=TRUE, xlim=extendrange(b,f=0.5))
这两部分代码后,我可以得到两个图像(A和B )。 但现在,我只想使用相同的坐标系直观的对比,画面像C.
这些照片都是这样来绘制两个图:
我应该写什么码?
http://www.statmethods.net/graphs/line.html会帮助你。我认为这是一个非常简单的问题。谷歌搜索就够了! – KrunalParmar