希腊字母为什么在R-Shiny绘图标题中使用’expression’命令时不显示?

huangapple go评论46阅读模式
英文:

Why are Greek letters not displayed in the R-Shiny plot title with the 'expression' command?

问题

Greek letters not displayed in R-Shiny using the command expression

以下R代码在本地正常工作,标题中的alpha正常显示:

require(shiny)
ui <- fluidPage(mainPanel(plotOutput(outputId="Plot")))
server <- function(input, output, session){
  output$Plot <- renderPlot({plot(0, 0, main=expression(alpha))})
}
shinyApp(ui=ui, server=server)

但在shiny服务器上,根本没有显示alpha。我不使用ggplot,只使用base-R。

有任何想法?

英文:

Greek letters not displayed in R-Shiny using the command expression

The following R-code works locally and the alpha is properly displayed in the title of the plot:

require(shiny)
ui &lt;- fluidPage(mainPanel(plotOutput(outputId=&quot;Plot&quot;)))
server &lt;- function(input, output, session){
output$Plot &lt;- renderPlot({plot(0, 0, main=expression(alpha))})
# }
shinyApp(ui=ui, server=server)

But on the shiny-server there appears no alpha at all. I do not use ggplot only base-R.

Any ideas?

答案1

得分: 1

它使用希腊字母的Unicode工作,例如 \alpha = \u03b1

    require(shiny)
    ui <- fluidPage(mainPanel(plotOutput(outputId="Plot")))
    server <- function(input, output, session){
    output$Plot <- renderPlot({plot(0, 0, main="\u03b1")})
    }
    shinyApp(ui=ui, server=server)
英文:

It works using the unicodes for the greek leters, in case of \alpha = \u03b1

require(shiny)
ui &lt;- fluidPage(mainPanel(plotOutput(outputId=&quot;Plot&quot;)))
server &lt;- function(input, output, session){
output$Plot &lt;- renderPlot({plot(0, 0, main=&quot;\u03b1&quot;)})
}
shinyApp(ui=ui, server=server)

huangapple
  • 本文由 发表于 2023年5月25日 15:10:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76329714.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定