I am able to change the background color in plotly bar charts by putting plot_bgcolor='rgb(0,0,0)'
in the layout
like :
library(plotly)
fig <- plot_ly(
x = c("giraffes", "orangutans", "monkeys"),
y = c(20, 14, 23),
name = "SF Zoo",
type = "bar"
)
fig %>% layout(uniformtext=list(minsize=8, mode='hide'),plot_bgcolor='rgb(0,0,0)')
But the same command does not work for plotly Pie chart !
USPersonalExpenditure <- data.frame("Categorie"=rownames(USPersonalExpenditure), USPersonalExpenditure)
data <- USPersonalExpenditure[,c('Categorie', 'X1960')]
fig <- plot_ly(data, labels = ~Categorie, values = ~X1960, type = 'pie')
fig <- fig %>% layout(title = 'United States Personal Expenditures by Categories in 1960',
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
plot_bgcolor='rgb(0,0,0)')
fig
It has still the white background!