How to set plotly chart to have a transparent background in R?
17,767
Solution 1
Just try:
salesplot <-plot_ly(producersales, type="scatter", x=Producer, y=SalesPerSong, color=SongRange, colors=cols, mode="markers", size=SalesPerSong) %>%
layout(xaxis = a, yaxis = a) %>%
layout(plot_bgcolor='rgb(254, 247, 234)') %>%
layout(paper_bgcolor='rgb(254, 247, 234)') #will also accept paper_bgcolor='black' or paper_bgcolor='transparent'
You can change the rgb numbers to fit your needs.
Solution 2
I find toy need to use rgba AND fig_bgcolor in layout
plt %>%
layout(plot_bgcolor = "rgba(0, 0, 0, 0)",
paper_bgcolor = "rgba(0, 0, 0, 0)",
fig_bgcolor = "rgba(0, 0, 0, 0)")
Author by
POW123
Updated on June 16, 2022Comments
-
POW123 almost 2 years
Here's what I have, so far:
f1 <- list( family = "Arial, sans-serif", size = 25, color = "white" ) f2 <- list( family = "Old Standard TT, serif", size = 14, color = "black" ) a <- list( title = "SALES PER SONG", titlefont = f1, showgrid = FALSE, showticklabels = TRUE, showline=TRUE, tickangle = 45, tickfont = f2 ) salesplot <-plot_ly(producersales, type="scatter", x=Producer, y=SalesPerSong, color=SongRange, colors=cols, mode="markers", size=SalesPerSong) %>% layout(xaxis = a, yaxis = a)
I tried adding
paper_bgcolor=#00000000, plot_bgcolor=#00000000
after the x and y axis information withinlayout()
, but when I run the command, I get the plus sign. I don't know what to do, so any help is appreciated. Thanks! -
Angelo over 3 yearsThis was useful even though plotly is telling me 'fig_bgcolor' is not a valid parameter.