我正在尝试创建一个由plot类型包装的ggplot2 facet.我已经习惯grid.arrange但我正在尝试最大化绘图区域,使用grid.arrange我松散区域由于y轴和图例的重复.
具体来说,我正在尝试创建一个在左边有一个BoxPlot的绘图,右边有相同数据的时间序列(因此相同的Y轴).然后我会有一个Y轴和一个单一的传奇 - 这可能吗?
代码:
library(ggplot2)
library(gridExtra)
Time = c("19/12/2013 10:00","19/12/2013 10:01", "19/12/2013 10:02", "19/12/2013 10:03", "19/12/2013 10:04",
"19/12/2013 10:05", "19/12/2013 10:06", "19/12/2013 10:07", "19/12/2013 10:08", "19/12/2013 10:09",
"19/12/2013 10:10", "19/12/2013 10:11", "19/12/2013 10:12", "19/12/2013 10:13", "19/12/2013 10:14")
test <- data.frame(Time)
test$Factor <- c("t1", "t1", "t1", "t1", "t1", "t1", "t1", "t1", "t1", "t2", "t2", "t2", "t2", "t2", "t2")
test$Values <- c(4,7,2,9,6,9,1,1,5,8,3,4,3,6,7)
test$PROD <- test$PROD <- c("one", "two", "one", "two", "one", "one", "two", "one", "one",
"two", "one", "two", …Run Code Online (Sandbox Code Playgroud)