向 R 图添加指数数

adding exponent numbers to R plot

提问人:confusedindividual 提问时间:11/16/2023 最后编辑:Darren Tsaiconfusedindividual 更新时间:11/16/2023 访问量:37

问:

有没有办法在轴标签的中间添加指数数? 如果我使用

expression(paste("Total Biomass (mg/", m^{3})))

我无法让它看起来像(想象 3 很小)。它看起来只会像没有,我也无法创建一个需要说的标签(想象一下 6 很小)。Total Biomass (mg/m3)Total Biomass (mg/m3)"Total Abundance (x106 cells/L)"

# create a dataset
set.seed(123)
specie <- c(rep("sorgho" , 3) , rep("poacee" , 3) , rep("banana" , 3) , rep("triticum" , 3) )
condition <- rep(c("normal" , "stress" , "Nitrogen") , 4)
value <- abs(rnorm(12 , 0 , 15))
df <- data.frame(specie,condition,value)
df

# Grouped
ggplot(df, aes(fill = condition, y = value, x = specie)) +
  labs(x = "Lakes", y = expression(paste("Total Plankton Biomass (mg/", m^{3}))) 
r ggplot2 标签

评论

5赞 Darren Tsai 11/16/2023
您错过了 中的右括号,即")"pastey = expression(paste("Total Plankton Biomass (mg/", m^{3}, ")"))

答: 暂无答案