Force R to write scientific notations as n.nn x 10^-n with superscript

后端 未结 1 1330
忘掉有多难
忘掉有多难 2021-01-21 05:14

Let\'s say I have two floats

a <- 8.9384920e-24
b <- 0.00293892837

I would like to display either of them in 10-base scientific notation

相关标签:
1条回答
  • 2021-01-21 05:31

    You may check eaxis in package sfsmisc

    # some data
    x <- seq(1, 100000, len = 10)
    y <- seq(1e-5, 1e-4, len = 10)
    
    # default axes
    plot(x, y)
    

    enter image description here

    # eaxis
    plot(x, y, axes = FALSE)
    eaxis(side = 1)
    eaxis(side = 2)
    

    enter image description here

    You may also create a label expression using pretty10exp() from the same package. For example to apply the format to a plot title:

    plot(x, y, axes = FALSE)
    title(pretty10exp(y[1]))
    

    enter image description here

    0 讨论(0)
提交回复
热议问题