将 xaxis 标签更改为特定字母 R
Change xaxis label to specific letters R
我在 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,我可以让它与字母一起工作,但当我想跳一些字母我遇到麻烦了。有人可以帮我吗?
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 那里得到了答案,我已经通过添加双井号描述的两个部分来修改您的代码。希望这有帮助。
我在 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,我可以让它与字母一起工作,但当我想跳一些字母我遇到麻烦了。有人可以帮我吗?
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 那里得到了答案,我已经通过添加双井号描述的两个部分来修改您的代码。希望这有帮助。