0

I am using shiny app & unable to get a transparent background only in this plot. After looking at many SO post I have tried a lot of options but still unable to get transparent background.

enter image description here

As you can see in the above image, the covid virus shape shouldn't hide behind the plot background if plot has transparent background.

 output$id_india_map_cases_daily <- renderPlot({
        req(input$id_checkbox_tab1_cases_daily)

        ind_states %>%
            filter(Date == max(Date, na.rm = TRUE),
                    State.UnionTerritory != "India") %>%

            ggplot(aes(fill = .data[[input$id_checkbox_tab1_cases_daily]], label = ST_NM)) +
            geom_sf(colour = "grey", lwd = .1) +
            theme_map() +
            scale_fill_gradient2_tableau(
                palette = "Sunset-Sunrise Diverging",
                na.value = "grey50",
                guide = "colourbar") +

            theme(legend.position = "right",
                  legend.direction = "vertical",
                  plot.title = element_text(size = 20),
                  panel.background = element_rect(fill = "transparent",colour = NA),
                  plot.background = element_rect(fill = "transparent",colour = NA),
                  strip.background = element_blank(),
                  panel.grid.major = element_blank(),
                  panel.grid.minor = element_blank(),
                  legend.background = element_rect(fill = NA),
                  legend.key = element_rect(fill = NA))

Is there any other theme option I can try with ?

I have another similar map down below in the App that uses same theme options but that one has transparency in the background & this can be confirmed if one changes the theme from light to dark for eg. cyborg

(UPDATE: removed app url)

(Pls close the App ASAP as this is running on free version of shinyapp which has monthly time limit).

ViSa
  • 1,563
  • 8
  • 30
  • 2
    Does this solve your issue? https://stackoverflow.com/a/50690259/6851825 – Jon Spring Aug 16 '21 at 07:40
  • @JonSpring, thanks for sharing this post. This did work. If you could share in the Answer then I will accept & close this post. Appreciate your help. Thanks again !! – ViSa Aug 16 '21 at 07:47

0 Answers0