ggplot2 graph quality in shiny on shinyapps.io

后端 未结 1 489
陌清茗
陌清茗 2021-02-04 04:19

Problem Summary: ggplot2 graphs seem to be of poor quality in shiny, when hosted on shinyapps.io. Graph elements contain visible defects, e.g. dots of

1条回答
  •  不知归路
    2021-02-04 04:53

    Since you're probably on a Linux-based server, you will likely need to use the Cairo graphical library.

    Cairo is a 2D graphics library with support for multiple output devices. Currently supported output targets include the X Window System (via both Xlib and XCB), Quartz, Win32, image buffers, PostScript, PDF, and SVG file output. Experimental backends include OpenGL, BeOS, OS/2, and DirectFB. Cairo is designed to produce consistent output on all output media while taking advantage of display hardware acceleration when available (eg. through the X Render Extension). Personally, I use it for the alpha channel (transparency options).

    Conveniently, there is an R implementation that creates a cairo graphics device in the "Cairo" package. In effect, you have to add the following chunk to 'server.R':

    #install.packages("Cairo")
    library(Cairo)
    options(shiny.usecairo=T)
    

    That should do it.

    PS: I see @MathewPlourde already answered this question in the comments.

    0 讨论(0)
提交回复
热议问题