x 轴不是从 R 中的 y=0 行开始

The x-axis does not start from the y=0 line in R

我用下面的代码创建了一个图

mydata <- c(20,40,60,30,70) #put as an example
myrange <- range(mydata)
plot(mydata2, type="o", col="blue", axes=F, ann=F)
axis(2, las=1, at=0:myrange[2])                       
axis(1, at=1:5, lab=c("Mon","Tue","Wed","Thu","Fri")) 

但是,x 轴不是从 y=0 行开始的。我该怎么办?

我把示例图放在下面:

如果我没理解错的话,轴线不相交。这可能会有所帮助...

将 xaxs 和 yaxs 参数添加到您的绘图调用中:

mydata2 <- c(20,40,60,30,70)

plot(mydata2, type="o", col="blue", axes=F, xaxs = "i",yaxs="i",ann=F, ylim=c(0, max(mydata2)))

axis(2, las=1, at=0:range(mydata2)[2])
                       
axis(1, at=1:5, lab=c("Mon","Tue","Wed","Thu","Fri"))