R中的漏斗图

qmelpv7a  于 2023-01-22  发布在  其他
关注(0)|答案(1)|浏览(106)

我们使用R脚本创建了一个漏斗图,但无法将背景颜色从白色更改为彩色#00355c
所用代码:

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")))

fig

期望将背景颜色从白色更改为#00355c

k5hmc34c

k5hmc34c1#

您需要在layout()中指定plot_bgcolorpaper_bgcolor或两者。
我用灰色和你确定的颜色来表示哪个参数做什么。

library(plotly)

(fig <- plot_ly(type = "funnel", 
               y = c("Invoiced", "Cancelled", "Collected", "Write Off", "Outstanding"),
               x = c(1, 3, 5, 7, 8)) %>%
  layout(yaxis = list(categoryarray = c("Invoiced", "Cancelled", "Collected", 
                                        "Write Off", "Outstanding")),
         plot_bgcolor = "#00355c", paper_bgcolor = "gray"))

相关问题