自动更改 facet_wrap 中多个箱线图的轴范围

问题描述 投票:0回答:0

我有多个变量,我希望为其绘制用 facet_wrap 扭曲的箱线图。 但是,当我这样做时,单个图被缩小,大部分图为空。 如何自动更改每个变量的 x 轴范围,以便优化每个单独的箱线图?

代码如下:

`Hist_grid<- data %>% select(-name) %>%
   pivot_longer(!type, names_to = "Name", values_to = "Value")

 Hist_grid %>% ggplot(aes(x = Value, fill = type)) +
   labs(fill = "Cell Type") +
   geom_boxplot(notch = T, outlier.shape = NA) + theme_bw() +
   facet_wrap(~Name,  shrink = T, scales = "free_x")`

/////////////////////////////////////////////// ////

ggplot2 boxplot
© www.soinside.com 2019 - 2024. All rights reserved.