17

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 within layout(), but when I run the command, I get the plus sign. I don't know what to do, so any help is appreciated. Thanks!

MLavoie
  • 9,671
  • 41
  • 36
  • 56
POW123
  • 316
  • 1
  • 3
  • 12
  • Please note that `paper_bgcolor=#00000000` returns a plus sign because `#` makes everything thereafter on the same line a comment, thereby negating your closing bracket. Replace with `paper_bgcolor = '#00000000' ` – Nibood_the_slightly_advanced Oct 18 '19 at 14:36
  • 1
    Note that transparent backgrounds will also apply to exported images. Which can render black label text invisible in some image viewing applications, including Windows 10's default Photos tool. – Kenneth M. Kolano Mar 30 '18 at 15:04

2 Answers2

33

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.

MLavoie
  • 9,671
  • 41
  • 36
  • 56
3

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)")
Benbob
  • 328
  • 2
  • 4