如何修改R语言Plotly漏斗图背景色为#00355c?
解决Plotly漏斗图背景色修改问题
要将漏斗图的背景色改为#00355c,只需在layout()中添加paper_bgcolor和plot_bgcolor参数,分别控制整个图表容器和绘图区域的背景色。修改后的完整代码如下:
library(plotly) fig <- plot_ly() fig <- fig %>% add_trace( type = "funnel", y = c("Invoiced", "Cancelled", "Collected", "Write Off", "Out Standing"), x = c(ZF_ZFO2CV001_OTC_002$`Net Invoiced (ABS)`, ZF_ZFO2CV001_OTC_002$`Cancelled (Net Invoiced)`, ZF_ZFO2CV001_OTC_002$`collected (ABS)`, ZF_ZFO2CV001_OTC_002$`Write Off (ABS)`, ZF_ZFO2CV001_OTC_002$`Outstanding Amount`)) fig <- fig %>% layout( yaxis = list(categoryarray = c("Invoiced", "Cancelled", "Collected", "Write Off", "Out Standing")), paper_bgcolor = "#00355c", # 整个图表容器的背景色 plot_bgcolor = "#00355c" # 绘图区域的背景色 ) fig
说明
paper_bgcolor:设置整个Plotly图表所在容器的背景色,包括坐标轴外侧的区域。plot_bgcolor:设置绘图区域(坐标轴包围的部分)的背景色。- 两个参数都设为#00355c,就能让整个图表背景统一为目标颜色。
内容的提问来源于stack exchange,提问作者Abhimanyu
相关产品推荐
相关产品推荐

