【发布时间】: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。
【问题讨论】:
我有一个关于线框图形选项的问题。我怎样才能使 xlab 和 ylab 平行于立方体 - 它们在我的情节中看起来很可怕,请参阅我的其他帖子
Faceted Lattice Plots in R, e.g., wireframes: How to remove strips and add 1-Line subtitles。
【问题讨论】:
您可以将列表传递给wireframe 的zlab、xlab 和ylab 参数。这些列表的一个组成部分可以是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))
【讨论】:
at = unique(round(pretty(pd$Petal.Width))) 包含在您的scales 列表中。此处概述了更彻底的方法:stackoverflow.com/q/12374622/1281189