【发布时间】:2020-12-30 03:45:43
【问题描述】:
【问题讨论】:
标签: r ggplot2 plot axis-labels scientific-notation
【问题讨论】:
标签: r ggplot2 plot axis-labels scientific-notation
我能想到的最好的办法是使用annotate() 函数并禁用坐标裁剪将文本放置在面板边界之外。您可能需要稍微调整一下确切的间距,表达式会引发警告。
library(ggplot2)
df <- data.frame(
x = 1:10,
y = 10:1
)
ggplot(df, aes(x, y)) +
geom_point() +
annotate("text", -Inf, Inf, label = expression(""%*%10^1),
hjust = 0, vjust = -1) +
annotate("text", Inf, -Inf, label = expression(""%*%10^-3),
hjust = 1, vjust = 2) +
coord_cartesian(clip = "off") +
theme(plot.margin = margin(t = 30, b = 10, l = 10, r = 10))
#> Warning in is.na(x): is.na() applied to non-(list or vector) of type
#> 'expression'
#> Warning in is.na(x): is.na() applied to non-(list or vector) of type
#> 'expression'
由reprex package (v0.3.0) 于 2020-09-11 创建
【讨论】: