4

I'm writing an R shiny app on a black background and need to change all plotly text to white. For some reason my code is not working:

  output$plotly_bar<- renderPlotly({
    plot_ly(FAID_mexico, x = ~Funding_Agency_Acronym,
        y = ~FAID_mexico$Current_Amount, 
        textfont = list(color = '#FFFFFF'),
        color = ~FAID_mexico$Policy_Area,
        textfont = list(color = '#FFFFFF')) %>%
      layout(plot_bgcolor='black')%>%
       layout(paper_bgcolor='black')
  })

texfont should be the function that changes all text color.

adarvishian
  • 175
  • 1
  • 3
  • 11

1 Answers1

5

Add your color to text in layout and it should work.

%>% layout(font = list(color = '#FFFFFF')) 

enter image description here

library(plotly)

p <- plot_ly(data = iris, 
             x = ~Sepal.Length, 
             y = ~Petal.Length,
             marker = list(size = 10,
                           color = 'rgba(255, 182, 193, .9)',
                           line = list(color = 'rgba(152, 0, 0, .8)',
                                       width = 2))) %>%
  layout(plot_bgcolor = 'black',
         paper_bgcolor = 'black',
         font = list(color = '#00FFFF')) 

p
Maximilian Peters
  • 30,348
  • 12
  • 86
  • 99