如何在 RStudio 中使用 ggplot2 将希腊符号添加到水平条形图上的 y 轴?

问题描述 投票:0回答:0

我正在尝试将水平条形图上的 y 轴标签更改为希腊符号,但我尝试过的任何方法都不起作用,它们一直被写成英文单词。我在 RStudio 中使用 ggplot2。我需要不同的包裹吗?我尝试过使用 $ eta$、表达式和“测试版”。也许我没有添加到代码的适当部分?我正在使用 .RData 文件,但我尝试在 Excel 中更改为符号,但 R 无法读取这些符号。

`load(file='CT.RData')
 paramNames <- names(par_fast)`

`#These are the titles I'd like to use on the y-axis. I read that [E] means this should be a subscript,          while ^NM should be a superscript, but I'm not getting that. I tried adding these names to the ggplot code    below in several locations, but I kept getting error messages.
#"r", "mu", "K", "omega[M]", "tau[E]", "tau[L]", "tau[N]", "eta[E]", "eta[L]", "eta[N]", "lambda", "omega", "omega[L]", "D", "delta", "nu", "beta[1]^ML", "beta[1]^NM", "gamma[1]", "beta[2]^ML", "beta[2]^NM", "sigma", "xi", "alpha"`

`doSensitivityPlot = function(varName, days, paramNames, sensitivities) {
  data <- expand.grid(X=days, Y=paramNames)       # grid of time points x parameter names
  data$Z <- array(sensitivities)                   # value (sensitivity) at each grid point

  ggplot(data, aes(X, Y, fill= Z)) + geom_tile(colour = "white") + 
      scale_fill_gradient(low = "white", high = "steelblue", name = "") + 
      labs(title = varName, x = "Day", y = "") + 
      theme(axis.text.y = element_text(size=7))}`

This is an example of my figure, I can get everything to run properly, I just can't change the y-labels to Greek symbols

symbols axis-labels
© www.soinside.com 2019 - 2024. All rights reserved.