r - 如何在简单的格子图中更改面板的顺序

标签 r plot lattice

嗨,我正在使用以下代码使用格子生成 xyplot

xyplot(Rate~Weight|Temp, groups=Week, rate,
 pch=c(15,16,17,3), col=c("blue","red","green","purple"),
 as.table=TRUE,
 xlab="Weight (gr)", ylab="Rate (umol/L*gr)",
 main="All individuals and Treatments at all times",
 strip=strip.custom(strip.names=1),
 key=
 list(text=list(c("Week","1","2","6","8")),
 points=list(pch=c(NA,15,16,17,3),col=c(NA,"blue","red","green","purple")),
 space="right")
 )

这给了我以下情节:
enter image description here

现在按照建议更改代码以包含面板顺序后:
xyplot(Rate~Weight|Temp, groups=Week, rate,
 index.cond=list(c(4,1,2,3)),#this provides the order of the panels
 pch=c(15,16,17,3), col=c("blue","red","green","purple"),
 as.table=TRUE,
 xlab="Weight (gr)", ylab="Rate (umol/L*gr)",
 main="All individuals and Treatments at all times",
 strip=strip.custom(strip.names=1),
 key=
 list(text=list(c("Week","1","2","6","8")),
 points=list(pch=c(NA,15,16,17,3),col=c(NA,"blue","red","green","purple")),
 space="right")
 )

我们得到了正确的顺序
enter image description here

谢谢您的帮助

最佳答案

我转换了 Temp考虑并得到这个:

enter image description here

您可以像这样调整因子顺序:

levels(rate$Temp) <- c("12", "9", "18", "15") #custom factor order

关于r - 如何在简单的格子图中更改面板的顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6358865/

相关文章:

r - `Rprof`的内存分析输出的解释

R 文本挖掘 : Counting the number of times a specific word appears in a corpus?

r - 如何防止嵌套 foreach 循环使用 R 中所有核心的 100% CPU?

r - R 中的时间序列与 ggplot2

r - 如何在绘图区域外的 geom_text() 中更改字体大小?

r - 调整网格中轴刻度之间的间距

r - 无法在 R 中安装 tseries 和预测包

r - 通过单击识别现有 splom 中的子面板

r - R 中多种图形类型的对齐(最好在 ggplot2 或 lattice 中)

c++ - C++ 实时 3D 可视化