在R图中仅关闭轴()的科学记数法

时间:2017-02-02 00:39:44

标签: r plot

我想知道科学记数是否可以在R中的axis()命令中关闭“本地”

下面是 R代码:

plot(1,1, type = "n", xlim = c(0,1.5), ylim = c(.1, 100000), ann=F,bty="n",yaxt="n")

axis(side=2, at = 10^(-1:5) )  ## HERE CAN I TURN SCIENTIFIC NOTATION OFF ##

2 个答案:

答案 0 :(得分:2)

我想您想要做的是在写标签时将其关闭,如下所示:

  

轴(边= 2,at = 10 ^( - 1:5),标签= c(格式(10 ^( - 1:5),科学=假)))

答案 1 :(得分:1)

axis内置的内容并非暂时禁用科学记数法。以下是几个选项:

# option 1: set the option and then reset it:
dsp = getOption("scipen")
options(scipen = 22)
axis(side=2, at = 10^(-1:5)) 
options(scipen = dsp)

# option 2: use format() to explicitly format the labels
plot(1,1, type = "n", xlim = c(0,1.5), ylim = c(.1, 100000), ann=F,bty="n",yaxt="n")
labs = 10^(-1:5)
axis(side = 2, at = labs, labels = format(labs, trim = T, scientific = F))

format是一个非常强大且灵活的格式化程序 - 它可能会在?format中记录。例如,您可能也有兴趣设置drop0trailing = T