我正在ggplot中创建图表,并希望将x轴刻度从科学格式更改为10 ^ n,20 ^ n,30 ^ n等格式,而无需将轴更改为对数刻度。我已经从该线程的注释部分复制了代码:
How can I format axis labels with exponents with ggplot2 and scales?
并对此稍作改动:
scale_x_continuous(label= function(x) {ifelse(x==0,"0",parse(text=gsub("[+]","",gsub("e","^",scientific_format()(x)))))} )
这给了我刻度轴标签,形式为1 ^ n,2 ^ n,3 ^ n等。有没有办法将其更改为10 ^ n,20 ^ n,30 ^ n等(显然为n-1 )?
非常感谢。