是否可以在 R 中使用 plotly 创建单个堆积柱形图

Is it possible to create single stacked column chart using plotly in R

我有一个数据框。

    Frequency <- data.frame(Type = c("Quarterly", "halfyearly", "Yearly", "Weekly", "Other"), 
Count = c(45, 13, 3, 18, 21))

这是预期的输出

是否可以使用 R 中的 plot_ly() 函数实现此目的?

任何人都可以提出一个合适的解决方案来实现这一目标。提前致谢!!!

是这样的吗?我不得不添加一个名为 "id" 的列,只是为了将其映射到 x 轴,但我认为它或多或少看起来像您想要的。

Frequency %>% 
    mutate(id = as.factor(1)) %>% 
    plot_ly(
    x = ~ id,
    y = ~ Count,
    color = ~Type,
    type = 'bar'
) %>% 
    layout(yaxis = list(title = 'Count'), barmode = 'stack')