3
我的问题有点奇怪。我有四种方法(M1,M2,M3和M4),每种方法都在两个独立阶段(T1和T2)以及10种不同尺寸(1,2,...,10)中进行了实验。下表显示了数据的结构:在ggplot2中混合facet_grid()和facet_wrap()
phase size mean stdev method T1 1 0.005 0.001 M1 T1 2 0.009 0.004 M1 T1 3 0.011 0.004 M1 ... T2 9 269.020 12.003 M4 T2 10 297.024 10.004 M4
第一阶段结果(T1)的范围小于第二阶段的范围。下面的命令生成的第一个情节
p <- ggplot(ds, aes(x=size, y=mean, color=method))
+ geom_line()
+ geom_smooth(aes(ymin=mean-stdev, ymax=mean+stdev), stat="identity")
+ scale_x_discrete(breaks=1:10)
+ labs(x="Size", y="Time in Seconds", fill="Method")
+ theme(panel.margin=unit(0.5, "lines"), legend.position="none")
+ facet_grid(method~phase, scales="free_y")
结果:
虽然下面的代码给出了第二个数字
p <- ggplot(ds, aes(x=size, y=mean, color=method))
+ geom_line()
+ geom_smooth(aes(ymin=mean-stdev, ymax=mean+stdev), stat="identity")
+ scale_x_discrete(breaks=1:10)
+ labs(x="Size", y="Time in Seconds", fill="Method")
+ theme(panel.margin=unit(0.5, "lines"), legend.position="none")
+ facet_wrap(method~phase, ncol=2, scales="free_y")
现在的问题是“我怎样才能使用facet_grid()
并强制y轴自由,类似于使用facet_wrap()
?“或“如何将facet_wrap()
的标签更改为与facet_grid()
类似?”
预先感谢您