【问题标题】:R: Lattice Plots/Wireframe : Graphical Issues with labelsR:格子图/线框:标签的图形问题
【发布时间】:2015-05-06 01:41:12
【问题描述】:

我有一个关于线框图形选项的问题。我怎样才能使 xlab 和 ylab 平行于立方体 - 它们在我的情节中看起来很可怕,请参阅我的其他帖子

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

【问题讨论】:

    标签: r lattice


    【解决方案1】:

    您可以将列表传递给wireframezlabxlabylab 参数。这些列表的一个组成部分可以是rot,它以度数指定轴标签应旋转的量。到目前为止,我只能通过反复试验将标签与轴“对齐”。

    ## 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))
    

    【讨论】:

    • 这看起来很不错!但是,我看到在 Petal.Width 轴上有两行刻度,我怎样才能删除“错误”的刻度?
    • 我认为只有一行刻度,但标签是用小数点后一位数字绘制的。因为他们太拥挤了,他们排成一排,看起来像两排。一个技巧是将at = unique(round(pretty(pd$Petal.Width))) 包含在您的scales 列表中。此处概述了更彻底的方法:stackoverflow.com/q/12374622/1281189
    猜你喜欢
    • 2015-01-22
    • 1970-01-01
    • 1970-01-01
    • 2017-06-15
    • 2016-02-11
    • 1970-01-01
    • 2018-01-23
    • 1970-01-01
    相关资源
    最近更新 更多