Usage geom_abline(mapping = NULL, data = NULL, ..., slope, intercept, na.rm = FALSE, show.legend = NA geom_vline(xintercept = 5) p + geom_vline(xintercept = 1:5) p + geom_hline(yintercept = 20) p + geom_abline () # Can't see it - outside the range of the data p + geom_abline(intercept = 20) # Calculate slope and of best fit coef(lm(mpg ~ wt, data = mtcars))(Intercept) wt 37.285126 -5.344472p + geom_abline
inverse.gaussian(link="log"),data=base 还可以考虑一些Tweedie分布,甚至更一般 考虑使用线性链接函数在第一种情况下获得的预测 plot(x,y,pch=19) abline (regNId,col=darkcols[1]) abline(regPId,col=darkcols[2]) abline(regGId,col=darkcols[3]) abline(regIGId ,col=darkcols[4]) abline(regTwId,lty=2) 这些预测非常接近。 plot(Vgamma,Verreur,type="l",lwd=3,ylim=c(-.1,.04),xlab="power",ylab="error") abline(h=0,lty=2) 当然
x <- seq(-10,10) y <- x ^ 2 plot(x, y, main="折线图", xlab="横坐标", ylab="纵坐标", type="o") abline(h=seq(0,100,10 ),col="grey") abline(v=seq(-10,10,1),col="grey") ? seq(0,100,10), side=2) #添加纵轴 box() #补齐散点图的边框 title(main="折线图", sub="subtitle", xlab="x轴", ylab="y轴") abline (h=seq(0,100,10),col="grey") abline(v=seq(-10,10,1),col="grey") #加上点 points(x,y) ? (h=seq(0,100,10),col="grey") abline(v=seq(-10,10,1),col="grey") #加上点 points(x,y,col="red",pch=16) ?
decreasing = T),las = 2) barplot(sort(table(x$Province),decreasing = T),las = 2,col = 'orange',border = F) abline (h =2) abline(h =4) abline(h =6) abline(h =8) abline(h =c(10,12,14)) tapply(x$Income,x$Province,mean)
因逻辑表达式结果要么0,要么1,故可用distance<1 num <- mean(b<1) pi <= 4*num pi par(bg="beige") plot(mx,col="azure3",asp = 1) abline (h=0,col="red",lty="dotdash",lwd=2) abline(h=2,col="red",lty="dotdash",lwd=2) abline(v=0,col="red",lty ="dotdash",lwd=2) abline(v=2,col="red",lty="dotdash",lwd=2) points(mx[b<1,],col="green") library(plotrix
(h=parameter[1]) + abline(h=parameter[1]+epesino) + abline(h=parameter[1]-epesino) + (h=1/parameter[1]) + abline(h=1/parameter[1]+epesino) + abline(h=1/parameter[1]-epesino) (h=(parameter[1]+parameter[2])/2) + abline(h=(parameter[1]+parameter[2])/2+epesino) + abline (h=parameter[1]) + abline(h=parameter[1]+epesino) + abline(h=parameter[1]-epesino) + (h=parameter[1]*parameter[2]) + abline(h=parameter[1]*parameter[2]+epesino) + abline(h=parameter
theme_bw() + #背景调整 labs(x = 'control group', y = 'treat group', color = '') + #坐标轴标题设置 geom_abline 0.58, slope = 1, col = 'black', linetype = 'dashed', size = 0.5) + #这3句用于添加 |log2FC|>1 的阈值线 geom_abline (intercept = -0.58, slope = 1, col = 'black', linetype = 'dashed', size = 0.5) + geom_abline(intercept theme_bw() + #背景调整 labs(x = 'control group', y = 'treat group', color = '') + #坐标轴标题设置 geom_abline (intercept = -1, slope = 1, col = 'black', linetype = 'dashed', size = 0.5) + geom_abline(intercept
geom_point(data=seed,aes(x=Perimeter,y=Area), size=5,color="red",alpha=0.3)+ geom_abline coefficients[[2]], size=2,color="blue",alpha=0.8)+ theme_bw() image.png 添加你和曲线的函数是geom_abline geom_point(data=seed,aes(x=Perimeter,y=Area), size=5,color="red",alpha=0.3)+ geom_abline geom_point(data=seed,aes(x=Perimeter,y=Area), size=5,color="red",alpha=0.3)+ geom_abline geom_point(data=seed,aes(x=Perimeter,y=Area), size=5,color="red",alpha=0.3)+ geom_abline
可以发现x轴和y轴的0点都不在原点的位置,会空出一小块,这样如果我们在加y=x等线条的时候回发生如下问题: p + geom_abline(slope = 1, intercept = 0) ? xlim和ylim的话会是这样: ggplot(data = mtcars, aes(x = wt, y = drat)) + geom_point(color = 'steelblue') + geom_abline 轴刻度从左下角开始可以这样: p + scale_x_continuous(expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0)) + geom_abline
abline(lm(y[ :k]~y[( :k)-52]),col="red") ? 时间序列是自相关的,在52阶 acf(y,lag=120) ? 对模型进行预测 plot(y,type="l",xlim=c(0,n ) abline(v=k,col="red") lines(pre4,col="blue") ? plot(y,type="l",xlim=c(0,n)) abline(v=k,col="red") ? plot(y,type="l",xlim=c(0,n)) ? plot(y,type="l",xlim=c(0,n)) abline(v=k,col="red") ?
参考线 我们可以使用abline()函数来在图形中添加直线,使用方法如下: abline(h=yvalues, v=xvalues) # 在y=1,5,7处添加三条水平线 abline(h=c(1,5,7 )) # 在x = 1,3,5,7,9添加三条垂直 abline(v=seq(1,10,2),lty=2,col="blue") ? # 在y=1,5,7处添加三条水平线 abline(h=c(1,5,7)) # 在x = 1,3,5,7,9添加三条垂直 abline(v=seq(1,10,2),lty=2,col="blue")
geom_point(shape=15) + #绘制拟合线 geom_smooth(method = 'lm',se = F,color='red',size=1) + #绘制对角线 geom_abline (slope = 1,intercept = 0,color='black',size=1) + #绘制上误差线 geom_abline(slope = 1.15,intercept = .05 ,linetype = "dashed",size=1) + #绘制下误差线 geom_abline(slope = .85,intercept = -.05,linetype = "dashed (slope = 1,intercept = 0,color='black',size=1) + #绘制上误差线 geom_abline(slope = 1.15,intercept = .05 ,linetype = "dashed",size=1) + #绘制下误差线 geom_abline(slope = .85,intercept = -.05,linetype = "dashed
(图3) 3.3 参考线 函数abline()可以用来添加参考线,格式如下: abline(h=yvalues,v=xvalues) 示例 attach(mtcars) plot(wt,mpg,main Car Weight') abline(h=c(min(mpg),mean(mpg),max(mpg))) detach(mtcars) attach(mtcars) plot(wt,mpg,main Car Weight abline(lm(mpg~wt))') abline(lm(mpg~wt)) detach(mtcars) ? ? (0,60),ylim = c(0,70)) #14行添加线条 lines(dose,drugB,type='b',pch=17,lty=2,col='blue') #17行添加辅助线 abline
上下调基因颜色赋值 theme_bw() + #背景调整 labs(x = 'control group', y = 'treat group', color = '') + #坐标轴标题设置 geom_abline intercept = 1, slope = 1, col = 'black', linetype = 'dashed', size = 0.5) + #这3句用于添加 |log2FC|>1 的阈值线 geom_abline (intercept = -1, slope = 1, col = 'black', linetype = 'dashed', size = 0.5) + geom_abline(intercept = theme_bw() + #背景调整 labs(x = 'control group', y = 'treat group', color = 'p-value') + #坐标轴标题设置 geom_abline (intercept = -1, slope = 1, col = 'black', linetype = 'dashed', size = 0.5) + geom_abline(intercept =
plot(gibbs_res[,1],type='l',xlab='MCMC Iterations',ylab=c('Coefficient Draw'), main='Intercept') abline ') plot(gibbs_res[,2],type='l',xlab='MCMC Iterations',ylab=c('Coefficient Draw'), main='Age1') abline ') plot(gibbs_res[,3],type='l',xlab='MCMC Iterations',ylab=c('Coefficient Draw'), main='Age2') abline plot(gibbs_res[,4],type='l',xlab='MCMC Iterations',ylab=c('Coefficient Draw'), main='Treatment') abline
,x1, y1):箭头:code=1则在各(x1,y1)处画箭头,code=2则在各(x0,y0)处画箭头,code=3则在两端都画箭头; angle控制箭头轴到箭头边的角度;length箭头长度; abline (h=y)在纵坐标y处画水平线,abline(v=x)在横坐标x处画垂直线;abline(a,b)绘制斜率为b和截距为a的直线;abline(lm.obj)画由lm.obj确定的回归线。 (0,19), font.main=3, las=1, col.main="red", col.sub="blue", col.lab="green", cex.lab=0.75) ##添加基本参数 abline
plot(density(residuals(fit))) plot(women$height,women$weight, xlab="hight", ylab="weight") abline coefficients(fit)) n = length(fitted(fit)) plot(hatvalues(fit),main="index plot of hat values") abline 对模型参数估计值影响有些比例失衡的点 cutoff <- 4/(nrow(states)-length(fit$coefficients)-2) plot(fit,which=4,cook.levels = cutoff) abline
第一个参数是X,第二个参数是Y abline(lm(mpg~wt)) #abline()函数主要是画一条直线 title("Regression of MPG on Weight") #给图添加上标题 jpeg("mygraph.jpg") #将最终姐果存为jpg格式 #接下来我们将之前画的图储存一下 attach(mtcars) pdf('mymtcars.pdf') plot(wt, mpg) abline
在整个图中画线可用abline()函数。 此函数有如下三种形式: abline(a,b),画一条直线,其中a是截距,b是斜率; abline(h=),画一条水平的直线,其中y轴的值由参数h=指定; abline(v=),画一条垂直的直线,其中x 使用abline()函数的例子: > x=(0:100)*2*pi/100 > y=sin(x) > plot(x,y,type="l",lty=1) > abline(h=0,lty=2) ?
abline(true.beta[1],0,lwd=2,col=2) ? abline(true.beta[2],0,lwd=2,col=2) ? abline(v=true.beta[2],lwd=2,col=2) ?