วิธีบังคับให้แกน y ส่งกลับค่าในรูปแบบทางวิทยาศาสตร์ใน R boxplot

ฉันจะบังคับให้แกน y แสดงตัวเลขในรูปแบบวิทยาศาสตร์ด้วย 'e' ได้อย่างไร ตัวอย่างเช่น แทนที่จะเป็น 0.01 ควรแสดง e-02 นี่คือรหัสของฉันด้านล่าง

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)

ป้อนคำอธิบายรูปภาพที่นี่


person math17    schedule 21.11.2020    source แหล่งที่มา
comment
รายการซ้ำที่เป็นไปได้: stackoverflow.com/questions/42323247/   -  person Kota Mori    schedule 21.11.2020
comment
@KotaMori ใช่ใน ggplot เป็นไปได้ แต่ในฟังก์ชัน boxplot ล่ะ ฉันพบว่าการใช้ boxplot ง่ายกว่า ggplot   -  person math17    schedule 21.11.2020
comment
@RonakShah ฉันได้ลองแล้วจริง ๆ แต่มันไม่ได้เปลี่ยนแปลงอะไรเลย   -  person math17    schedule 21.11.2020


คำตอบ (1)


คุณอาจต้องทำอะไรแบบนี้

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)

ป้อนคำอธิบายรูปภาพที่นี่

person Kota Mori    schedule 21.11.2020