我有这个情节太拥挤而无用:
ggplot(data = meandist.SG, aes(x = starttime,y = meandist)) + #set main plot variables
geom_ribbon(aes(ymin=meandist-se, ymax=meandist+se, fill=mapped), alpha=0.1) + #add standard error
geom_line(aes(colour = mapped),alpha = 1) + #add a line for each group
labs(title = "Comparison of Groups", x = "time (s)", y = "mean distance (mm)") #set title, and axis labels
我可以通过将以下内容包装在 mlply 中并传入可能的组对来为每对组绘制一个图。但这意味着我不能同时看到所有的情节。
ggplot(data = subset(meandist.SG, mapped %in% c('a', 'f')) ,aes(x = starttime,y = meandist)) + #set main plot variables
geom_ribbon(aes(ymin=meandist-se, ymax=meandist+se, fill=mapped), alpha=0.1) + #add standard error to main plot
geom_line(aes(colour = mapped),alpha = 1,size = 1) + #plot a line on main plot for each group
labs(title = 'GroupA and GroupB, Distance over Time', x = "time (s)", y = "mean distance (mm)")
我想做的是创建一个图像,其中成对的组图像对角图一样排列,mapped
因子作为对角线。
数据如下所示:
> str(meandist.SG)
'data.frame': 2400 obs. of 4 variables:
$ starttime: num 0 0 0 0 0 0 0 0 60 60 ...
$ mapped : Factor w/ 8 levels "rowA","rowB",..: 1 2 3 4 5 6 7 8 1 2 ...
$ meandist : num 123.2 115 91.9 112.8 108.6 ...
$ se : num 8.95 9.54 9.57 9.86 11.96 ...
> head(meandist.SG)
starttime mapped meandist se
1 0 rowA 123.1739 8.952757
2 0 rowB 114.9875 9.544961
3 0 rowC 91.8875 9.571005
4 0 rowD 112.7583 9.861424
5 0 rowE 108.5826 11.962127
6 0 rowF 126.4917 9.331622
我想我应该使用GGally包,但我不知道如何使用因子的水平作为对角线。想法?