You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用ggplot2绘制多维度分类调研数据,替代杂乱柱状图展示方案

清洁产品消费者满意度调研可视化优化需求

项目背景

针对两款清洁产品(Product A、Product B)开展消费者满意度市场调研,调研数据按三个维度拆分:

  • 使用房间:Kitchen、Bathroom、Bedroom
  • 使用频率:Daily、Weekly、Monthly
  • 产品瓶身尺寸:Small、Medium、Large

现有方案问题

最初选择柱状图作为结果展示方式,但呈现效果未达预期:最小可复现示例(MWE)中的数据为升序排列,而真实数据中不同柱子尺寸差异大,导致图表视觉效果非常杂乱,需要寻求更合适的可视化呈现方案。

最小可复现代码(MWE)

library(ggplot2)

Product <- c("Product A", "Product B")
Place <- c("Kitchen", "Bathroom", "Bedroom")
Bottle_size <- c("Small", "Medium", "Large")
Frequency <- c("Daily", "Weekly", "Monthly")

DF <- expand.grid(Bottle_size = Bottle_size,
                  Place = Place,
                  Frequency = Frequency,
                  Product = Product)

DF$Consumer_Approval <- seq(from = 10,
                            to = 100,
                            by = (100-10)/53)

ggplot(data = DF,
       aes(x = Frequency,
           y = Consumer_Approval)) +
  geom_col(aes(fill = Bottle_size),
           position = "dodge") +
  facet_grid(Product ~ Place)

效果参考

MWE效果图、真实数据效果图见原提问附带素材


内容的提问来源于stack exchange,提问作者DVCar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.02 15:27:05