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

Yosu Yurramendi yo@u@yurr@mend| @end|ng |rom gm@||@com
Mon Jun 17 19:38:21 CEST 2024


Thank you all very much for the answers given (Greg, Robert, Duncan,
Roland).

Actually, I had tried with "#00000000" and "#FFFFFF00" (I had a mistake in
the message). For example it works with:

numrows <- 3; numcols <- 3
a <- c(1,0,1,1,1,1,1,0,1)
(pattern <- matrix(a, numrows, numcols, byrow=TRUE))
#
png(filename="transparency.00.png")
par(bg="#00000000")
palette <- c("#00000000", "black")
image(t(pattern), col = palette, axes = FALSE)
dev.off()

I took into account Duncan's answer: 'If the other answers don't solve your
problem, you should give us some context.  Not all graphics functions in R
can handle transparency, so please show us some reproducible code for what
you are trying.'

But it doesn't work on Shiny.
library(shiny)

# Define UI for application that draws a histogram
ui <- fluidPage(
   titlePanel(h3("Binary pattern (r,c)-rectangular grid", align =
"center")),
   sidebarLayout(
     sidebarPanel(
       numericInput("r", "Number of rows:", 3),
       numericInput("c", "Number of columns:", 3)
     ),
    mainPanel(plotOutput("distPlot"))
  )
)
server <- function(input, output) {
  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)
  })
}
shinyApp(ui = ui, server = server)

Any explanation? Any help?

Thanks


Hau idatzi du Yosu Yurramendi (yosu.yurramendi using gmail.com) erabiltzaileak
(2024 eka. 6(a), og. (10:37)):

> What is the HEX code for "transparent" color?
> I've tried "00000000" "FFFFFF00" "FFFFFFFF", but they don't work.
> Thanks
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list