2

I am trying to make an app with transparent plots on different background colors. The problem is that text on the plots looks very low resolution.

The same question has been asked low resolution in R ggplot2 plots with transparent background on Shiny app but with no MRE and is not answered.

Here is an MRE:

library(shiny)

transparent_theme = theme_bw(20) + theme(
  panel.background = element_rect(fill = "transparent"), 
  plot.background = element_rect(fill = "transparent", color = NA), 
  panel.grid = element_blank(),
  panel.border = element_blank(),
  axis.line = element_line()
)


ui = fluidPage(
  tags$style('.container-fluid { background-color: #007BA7;}'),
  plotOutput("test")
)

server = function(input, output){
  output$test = renderPlot({

    X = data.frame(x=1:10, y=1:10)

    ggplot(X, aes(x=x, y=y)) + geom_point(size=5) + ggtitle("Test") +
      transparent_theme


  }, bg = "transparent") 
}

shinyApp(ui, server)
Adam Waring
  • 1,158
  • 8
  • 20

0 Answers0