[R] What is the HEX code for "transparent" color?

Ivan Krylov |kry|ov @end|ng |rom d|@root@org
Thu Jun 20 18:07:50 CEST 2024


В Mon, 17 Jun 2024 19:38:21 +0200
Yosu Yurramendi <yosu.yurramendi using gmail.com> пишет:

>   output$distPlot <- renderPlot({
>     numrows <- 3; numcols <- 3
>     a <- c(1,0,1,1,1,1,1,0,1)
>     pattern <- matrix(a, numrows, numcols, byrow=TRUE)
>         palette <- c("#00000000", "black")
>         par(bg="#00000000")
>     #
>     image(t(pattern), col = palette, axes = FALSE)
>   })

Shiny is a bit different.

First of all, try to use the Web Developer toolbar in your browser to
look at the plot image that gets served to you. It could be that the
image has transparent background, but some other element that
encompasses the image may have a non-transparent background. You may
need to style the rest of the output somehow.

If the image does have a non-transparent background, try passing the
argument bg = 'transparent' to renderPlot. The documentation [*] says
that the arguments are passed to plotPNG(...) and, eventually, to
ragg::agg_png(...) / png(...) / Cairo::CairoPNG(), all of which should
support the parameter.

-- 
Best regards,
Ivan

[*] https://search.r-project.org/CRAN/refmans/shiny/html/renderPlot.html



More information about the R-help mailing list