【问题标题】:R Shiny: mathematical symbols in plotsR Shiny:图中的数学符号
【发布时间】:2021-05-25 14:39:13
【问题描述】:

绘图标签中的数学注释不会在闪亮的应用程序中呈现。 都带有基本图形和 ggplot2。

这是一个使用 plotmath 表达式和 UTF-8 字符的最小示例。 在 R 中以交互方式打印绘图或通过图形设备(例如 png())保存可正确呈现符号。 然而,在下面闪亮的应用程序中,符号根本没有呈现。

library(shiny)

ui <- fluidPage(
  fluidRow(
    column(4, plotOutput("figure1", height = "300px")), 
    column(4, plotOutput("figure2", height = "300px")), 
    column(4, plotOutput("figure3", height = "300px"))
  )
)

server <- function(input, output, session) {
  output$figure1 <- renderPlot(
    plot(1, xlab = "beta")
  )
  output$figure2 <- renderPlot(
    plot(1, xlab = expression(beta))
  )
  output$figure3 <- renderPlot(
    plot(1, xlab = "????")
  )
}

runApp(shinyApp(ui, server))

会话信息:

R version 4.1.0 (2021-05-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 20.1

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8     LC_MONETARY=fr_FR.UTF-8   
 [6] LC_MESSAGES=en_GB.UTF-8    LC_PAPER=fr_FR.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
[1] shiny_1.6.0    devtools_2.4.1 usethis_2.0.1 

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.6        compiler_4.1.0    bslib_0.2.5.1     later_1.2.0       jquerylib_0.1.4   prettyunits_1.1.1 remotes_2.3.0     tools_4.1.0      
 [9] testthat_3.0.2    digest_0.6.27     pkgbuild_1.2.0    pkgload_1.2.1     jsonlite_1.7.2    memoise_2.0.0     lifecycle_1.0.0   rlang_0.4.11     
[17] cli_2.5.0         parallel_4.1.0    fastmap_1.1.0     withr_2.4.2       desc_1.3.0        fs_1.5.0          sass_0.4.0        rprojroot_2.0.2  
[25] glue_1.4.2        R6_2.5.0          processx_3.5.2    bspm_0.3.7        sessioninfo_1.1.1 callr_3.7.0       purrr_0.3.4       magrittr_2.0.1   
[33] ps_1.6.0          promises_1.2.0.1  ellipsis_0.3.2    htmltools_0.5.1.1 mime_0.10         xtable_1.8-4      httpuv_1.6.1      cachem_1.0.5     
[41] crayon_1.4.1      Cairo_1.5-12.2   

【问题讨论】:

  • 它对我有用。我在 Ubuntu 20.04 上使用 R 版本 4.1.0 和闪亮版本 1.6.0。
  • 感谢您的报告。我正在使用 R v4.0.5 和闪亮的 v1.5.0。将升级并报告它是否解决了问题。
  • 您在图 2 中的 expression(beta) 对我有效,但对图 3 中的直接声明无效。
  • 在 Linux Mint 20.1(派生自 Ubunty 20.04)上升级到 R v4.1.0 和闪亮 v1.6.0,并且行为仍然与报告的示例中的相同(缺少符号)。正在升级所有其他要检查的软件包。
  • 升级所有包后,问题依旧。在帖子中添加了当前会话信息。

标签: r shiny


【解决方案1】:

问题通过设置解决

options(shiny.usecairo = FALSE)

如果安装了 Cairo 包,它将禁用图形渲染。见https://shiny.rstudio.com/reference/shiny/0.12.0/shiny-options.html

【讨论】:

    猜你喜欢
    • 2020-06-19
    • 2018-01-03
    • 1970-01-01
    • 2018-09-23
    • 2020-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多