How to set up a graph for transparent background in R?

Here is what I have:

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 to add paper_bgcolor=#00000000, plot_bgcolor=#00000000 after the x and y axis information within layout() , but when I run the command, I get a plus sign. I do not know what to do, so any help is appreciated. Thanks!

+5
source share
2 answers

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 suit your needs.

+8
source

Please note that transparent backgrounds will also apply to exported images. This can make the black label text invisible in some image viewer applications, including the Windows Photos Default Photos tool.

0
source

All Articles