小编Chr*_*rys的帖子

如何协调 facet_wrap 和 scale="free_y" 中的轴?

我想绘制连续变量和分类变量(geom_boxplotwith ggplot2)之间关系的箱线图,这适用于几种情况(facet_wrap)。很简单:

data("CO2")
ggplot(CO2, aes(Treatment, uptake) ) + 
  geom_boxplot(aes(Treatment, uptake), 
               col="black", fill="white", alpha=0, width=.5) + 
  geom_point(col="black", size=1.2) + 
  facet_wrap(~Type, ncol=3, nrow=6, scales= "free_y") + 
  theme_bw() + 
  ylab("Uptake")
Run Code Online (Sandbox Code Playgroud)

结果: 在此处输入图片说明

This is quite nice with this toy dataset, but applied to my own data (where facet_wrap enables me to plot 18 different graphs) the y-axes are hardly readable, with varying number of y-ticks and varying spacing between them:

在此处输入图片说明

What could be a nice way to harmonize the …

r ggplot2

5
推荐指数
1
解决办法
904
查看次数

标签 统计

ggplot2 ×1

r ×1