首页 文章

R:Lattice Plots / Wireframe:带标签的图形问题

提问于
浏览
1

我有一个关于线框图形选项的问题 . 如何让xlab和ylab与多维数据集平行 - 它们在我的情节中看起来很糟糕,请参阅我的其他帖子

Faceted Lattice Plots in R, e.g., wireframes: How to remove strips and add 1-Line subtitles .

1 回答

  • 2

    您可以将列表传递给 wireframezlabxlabylab 参数 . 这些列表的一个组成部分可以是 rot ,它以度为单位指定轴标签应旋转的量 . 到目前为止,我只能通过反复试验来确定带有轴的标签"align" .

    ## Code from your other post, to make this reproducible
    model_test <- lm(Sepal.Length ~( Petal.Length + Sepal.Width + Petal.Width +Species)^2,
        data=iris)
    gg<-expand.grid(Petal.Length=0:6,Species=levels(iris$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))
    
    ## Plot with rotated axis labels
    wireframe(pred~Sepal.Width+Petal.Width|Species*Petal.Length,
               pd, drape=FALSE,scale=list(arrows=FALSE),subset=(Species=="setosa"),
               layout = c(3, 3), zlab = list("pred", rot = 90),
               xlab = list("Sepal.Width", rot = 30),
               ylab = list("Petal.Width", rot = -30))
    

    enter image description here

相关问题