Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change all text color in Plotly R

Tags:

r

shiny

plotly

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.

like image 688
adarvishian Avatar asked Sep 06 '25 03:09

adarvishian


1 Answers

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
like image 182
Maximilian Peters Avatar answered Sep 07 '25 19:09

Maximilian Peters