1

我正在尝试在每个小提琴图中创建带有箱线图的小提琴图。目前,箱线图是根据 x 变量创建的,同时结合填充分组。我希望每个 x 变量的每个填充组都有一个箱线图。

谢谢您的帮助!

ggplot(aes(y = HGT.Diff,
           x = `Platform`,
           fill = Metric,
           color = Metric),
       data = dta_compile) +
  geom_violin(draw_quantiles = c(0.5)) +
  geom_boxplot(width = 0.1, fill = "grey", color = "black") +
  ylim(0,1) +
  labs(title = "Comparing Ground Filters",
       x = "Flight Date", 
       y = "Absolute Difference to Manual HGT Measurmenets (m)") +
  theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust=.4)) +
  facet_grid(`Flight.Date` ~ `GroundFilter`)

上述脚本的当前小提琴情节

4

1 回答 1

4

通过在小提琴和箱线图中加入闪避设置,获得了预期的结果。感谢您的帮助!

ggplot(aes(y = HGT.Diff,
       x = `Platform`,
       fill = Metric,color=Metric),
       data = dta_compile) +
geom_violin(position=position_dodge(),draw_quantiles=c(0.5)) +
geom_boxplot(width=0.1,color="black",position = position_dodge(width =0.9))+
ylim(0,1) +
labs(title="Comparing Ground Filters",
     x="Flight Date", 
     y="Absolute Difference to Manual HGT Measurmenets (m)") +
theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust=.4)) +
facet_grid(`Flight.Date`~`GroundFilter`)

修订小提琴情节

于 2018-09-27T17:08:30.690 回答