Open MadhulikaTanuboddi opened 4 years ago
Here's a more minimal example which makes the issue more obvious (the background color should be blue):
library(shiny)
library(thematic)
ui <- fluidPage(plotOutput("base"))
server <- function(input, output, session) {
output$base <- renderPlot({
thematic_with_theme(thematic_theme(bg = "blue", fg = "red"), {
plot(1:10, 1:10)
})
})
}
shinyApp(ui, server)
I'm not sure if this is something that makes sense for thematic to fix...the core issue here is that Cairo::CairoPNG()
doesn't respect par(bg = ...)
, so there are at least 2 workarounds:
Use a different graphics device than Cairo::CairoPNG()
. That can be done with either options(shiny.usecairo = FALSE)
or options(shiny.useragg = TRUE)
(requires shiny v1.5).
Set bg = thematic_get_option("bg")
in renderPlot()
, so for example:
renderPlot({
thematic_with_theme(thematic_theme(), {
plot(1:10, 1:10)
})
}, bg = thematic_get_option("bg"))
Run the following example on RStudio Server Pro
Notice that base graph is not displayed as expected.