我有多个变量,我希望为其绘制用 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")`
/////////////////////////////////////////////// ////