R中的多面格子图,例如线框:如何删除条带并添加1行字幕 [英] Faceted Lattice Plots in R, e.g., wireframes: How to remove strips and add 1-Line subtitles

查看:66
本文介绍了R中的多面格子图,例如线框:如何删除条带并添加1行字幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这种功能(来自虹膜数据集)

I use this kind of function (from iris data set)

model_test <- lm(Sepal.Length ~( Petal.Length + Sepal.Width + Petal.Width +Species)^2,
data=iris)
gg<-expand.grid(Petal.Length=0:6,Species=levels(Species))
vv<-expand.grid(Sepal.Width=0:4,Petal.Width=1:4)

pd<-do.call(rbind,Map(function(Petal.Length,Species,Sepal.Width,Petal.Width){
              nd <- cbind(vv, Petal.Length=Petal.Length,Species=Species,
                               Sepal.Width=Sepal.Width, Petal.Width=Petal.Width)
              cbind(nd, pred=predict(model_test, nd, type="response"))},
              Petal.Length=iris$Petal.Length,Species=iris$Species,
               Sepal.Width=iris$Sepal.Width,Petal.Width=iris$Petal.Width))

wireframe(pred~Sepal.Width+Petal.Width|Species*Petal.Length,
           pd, drape=FALSE,scale=list(arrows=FALSE),subset=(Species=="setosa"),
           layout = c(3, 3))

我得到这个情节

我的问题: 如果我在模型中包括更多因素,则(彩色)条带将使图非常小.如何删除绿色和浅红色的条带并添加1行标题 像Species==setosa & Petal.Length==0,....,Species==setosa & Petal.Length==6.

My Question(s): If I include more factors in my model, the (coloured) strips would make the plots very small. How can I remove the green and light red strip and add a 1-Line Title like Species==setosa & Petal.Length==0,...., Species==setosa & Petal.Length==6.

推荐答案

Lattice将为每个条件变量创建一个带.如果只需要一个试条,请尝试根据交互条件进行调整.例如

Lattice is going to create a strip for each conditioning variable. If you want just one strip, try conditioning on the interaction. For example

wireframe(pred~Sepal.Width+Petal.Width|interaction(Species,Petal.Length),
           pd, drape=FALSE,scale=list(arrows=FALSE), subset=(Species=="setosa"), layout=c(3,3))

给出

您可以提前创建交互并根据需要自定义级别.

You can create the interaction ahead of time and customize the levels if you like with whatever description you want.

这篇关于R中的多面格子图,例如线框:如何删除条带并添加1行字幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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