如何在 R boxplot 中以科学计数法将 y 轴强制为 return 值
How to force y axis to return values in scientific notation in R boxplot
如何强制 y 轴以科学计数法显示数字 'e'。例如,它应该显示“e-02”而不是 0.01。下面是我的代码。
boxplot(large1k$Damping_error,small1k$Damping_error,large4k$Damping_error,small4k$Damping_error,large8k$Damping_error,small8k$Damping_error,large16k$Damping_error,small16k$Damping_error,large32k$Damping_error,small32k$Damping_error,col=c("blue","red","blue","red","blue","red","blue","red","blue","red"),names=c("1k","1k","4k","4k","8k","8k","16k","16k","32k","32k"),las.y=1,xlab="Sample size",ylab="Damping error",log="y",cex.axis=1.2,cex.lab=1.3)
你可能需要做这样的事情。
labels_at <- seq(0, 25, 5)
labels <- scales::label_scientific(digits=2)(labels_at)
boxplot(count ~ spray, data = InsectSprays, col = "lightgray", yaxt="n")
axis(side=2, at=labels_at, labels=labels)
如何强制 y 轴以科学计数法显示数字 'e'。例如,它应该显示“e-02”而不是 0.01。下面是我的代码。
boxplot(large1k$Damping_error,small1k$Damping_error,large4k$Damping_error,small4k$Damping_error,large8k$Damping_error,small8k$Damping_error,large16k$Damping_error,small16k$Damping_error,large32k$Damping_error,small32k$Damping_error,col=c("blue","red","blue","red","blue","red","blue","red","blue","red"),names=c("1k","1k","4k","4k","8k","8k","16k","16k","32k","32k"),las.y=1,xlab="Sample size",ylab="Damping error",log="y",cex.axis=1.2,cex.lab=1.3)
你可能需要做这样的事情。
labels_at <- seq(0, 25, 5)
labels <- scales::label_scientific(digits=2)(labels_at)
boxplot(count ~ spray, data = InsectSprays, col = "lightgray", yaxt="n")
axis(side=2, at=labels_at, labels=labels)