图上打印了一个额外的字符“1”。为什么会这样以及如何消除这种情况?
MWE:
data <- ChickWeight
par(mar = c(4,4,0.5,0.5) + 0.1, mgp = c(2.75,1,0), las = 1, cex = 1.2)
data.lm <- lm(weight ~ Time, data = data)
plot(weight ~ Time, data = data, col = "magenta", pch = 19, ylab = "Weight (gms)", xlab = "Time (days)", ylim = c(25, 375), xlim=c(0,22))
abline(data.lm, col="blue", lty = 2, lwd = 2)
a <- round(data.lm$coefficients[[1]], 2)
b <- round(data.lm$coefficients[[2]], 2)
# err <- format(mean(data.lm$residuals), scientific = TRUE, digits = 3) # its not working leaving a "1" at the end of the equation. No idea, why?
err <- round(mean(data.lm$residuals),17)
# equation of the line :
eq <- paste("Weight =",a,"+",b,"\u00D7 Time",err,cex=1)
mtext(paste(eq),side=3,line=-1.1,padj=-0.25,adj=0.05,cex=0.8)
2条答案
按热度按时间ifmq2ha21#
您可以在
mtext
中使用cex
一次,如下所示:创建于2023-05-17带有reprex v2.0.2
2skhul332#
已解决: