Mixing facet_grid () and facet_wrap () in ggplot2

My question is a bit strange. I have four methods (M1, M2, M3 and M4), each of which was experimented in two independent phases (T1 and T2) and 10 different sizes (1, 2, ..., 10). The following table shows the data structure:

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

The range of the results of the first phase (T1) is less than that of the second phase. The following command generates the first chart

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")

Result: The use of facet_grid ()
Although the following code gives the second digit

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")

The use of facet_wrap ()
: " facet_grid() y , facet_wrap()?" " facet_wrap(), facet_grid()?"

+3
1

EDIT: , , OP, , , .

, , , facet_grid, , M T:

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(phase~method, scales="free_y")

enter image description here

facet_grid Y , , , .

+1

All Articles