我在R中制作了很多图,我的代码的一部分看起来像这样:
plot(x=0,y=0, type="n", ylim=c(0,250), xlim=c(0,8), bty="n", main = "Line 20 male 3 sec rep 2",
xlab = "Concentration", ylab = "MM above buttom")
fc <- levels(dat20m2$Conc)
for(i in 1:length(fc)){
tmp <- dat20m2[dat20m2$Conc==fc[i],]
points(y=tmp$t30.sum,x=rep(i,length(tmp$t30)))
points(y=mean(tmp$t30.sum),x=i,col="red")
}
abline(lm(t30.sum~as.integer(Conc),data=dat20m2), lty=2)
我的x轴是从0:8但我想要的是A,B,C,D,E,X,Y和我可以使它与字母表一起工作但是当我想跳一些字母我陷入困境。有人可以帮助我吗?
答案 0 :(得分:1)
plot(x=0,y=0, type="n", ylim=c(0,250), xlim=c(0,8), bty="n", main = "Line 20 male 3 sec rep 2",
xlab = "Concentration", ylab = "MM above buttom", xaxt="n")
## added xaxt="n"
## and the axis code below
axis(1,at=0:7,labels=c("0","A","B","C","D","E","X","Y"))
fc <- levels(dat20m2$Conc)
for(i in 1:length(fc)){
tmp <- dat20m2[dat20m2$Conc==fc[i],]
points(y=tmp$t30.sum,x=rep(i,length(tmp$t30)))
points(y=mean(tmp$t30.sum),x=i,col="red")
}
abline(lm(t30.sum~as.integer(Conc),data=dat20m2), lty=2)
我从here得到了答案,我通过添加双磅符号描述的两个部分来修改你的代码。希望这会有所帮助。