与John Fox的效果图进行grid.arrange [英] grid.arrange with John Fox's effects plots

查看:97
本文介绍了与John Fox的效果图进行grid.arrange的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一个窗口中将多个效果图与效果包组合在一起,但是不知道是否有一种简便的方法.

I'd like to combine multiple effect plots in one window with the effects package, but don't know if there is an easy way to do so.

这是一个不起作用的示例:

Here's an example that doesn't work:

d1 <-data.frame(x1=rnorm(100,0:10),y1=rnorm(100,0:10),x2=rnorm(100,0:10),y2=rnorm(100,0:10))
require(effects)
require(gridExtra)
plot1 <- plot(allEffects(mod=lm(y1~x1,d1)))
plot2 <- plot(allEffects(mod=lm(y2~x2,d1)))
grid.arrange(plot1,plot2,ncol=2)

推荐答案

我认为您需要收集allEffects组件的值,然后将它们绘制为效果列表".在我看来,该图是基础图形,但是如果您遵循类函数路径(或者如果您阅读:?plot.efflist)

I think you need to collect the values of allEffects components and then plot them as an 'efflist'. It looked to me that the plotting was base-graphics, but it is in fact 'lattice' if you follow the class-function trail (or if you read: ?plot.efflist )

尝试一下:

ef1 <-allEffects(mod=lm(y1~x1,d1))[[1]]
ef2 <- allEffects(mod=lm(y2~x2,d1))[[1]]
elist <- list( ef1, ef2 )
class(elist) <- "efflist"
plot(elist, col=2)

这篇关于与John Fox的效果图进行grid.arrange的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆