这可能是一个非常基本的问题,但我正在努力改变xyplot中的图形参数(下图)。目标是将回归线的颜色更改为红色,将数据点更改为蓝色。
我已经基本尝试了以下代码,但是当我在代码中添加 pch = 19 和 col =“blue”时,颜色不会改变。
如果有人可以提供帮助,我将非常感激。
XY图的R代码
##Create a vector
Z3 <- as.vector(as.matrix(Pairs[, c("Lighting",
"Distance_Coast",
"Temp_Canopy",
"Temp_Open",
"T.max.open",
"T.min.open",
"T.min.canopy",
"T.max.canopy")]))
#Setup the data in vector format for the xyplot
Y10 <- rep(Pairs$Canopy_index, 8)
MyNames <-names(Pairs[,c("Lighting",
"Distance_Coast",
"Temp_Canopy",
"Temp_Open",
"T.max.open",
"T.min.open",
"T.min.canopy",
"T.max.canopy")])
ID10 <- rep(MyNames, each = length(Pairs$Canopy_index))
ID11 <- factor(ID10, labels = c("Lighting",
"Distance_Coast",
"Temp_Canopy",
"Temp_Open",
"T.max.open",
"T.min.open",
"T.min.canopy",
"T.max.canopy"),
levels = c("Lighting",
"Distance_Coast",
"Temp_Canopy",
"Temp_Open",
"T.max.open",
"T.min.open",
"T.min.canopy",
"T.max.canopy"))
##XY Plot
xyplot(Y10 ~ Z3 | ID11, col = 1,
strip = function(bg='white',...) strip.default(bg='white',...),
scales = list(alternating = T,
x = list(relation = "free"),
y = list(relation = "same")),
xlab = "Explanatory Variables",
par.strip.text = list(cex = 0.8),
ylab = "Canopy Index",
panel=function(x, y, subscripts,...){
panel.grid(h =- 1, v = 2)
panel.points(x, y, col = 1, pch = 16)
if(ID10[subscripts][1] != "Minutes.After.Sunset") {panel.loess(x,y,col=1,lwd=2)}
})
XY绘图
答案 0 :(得分:1)
这是答案:
##XY Plot
xyplot(Y10 ~ Z3 | ID11, col = 1,
strip = function(bg='white',...) strip.default(bg='white',...),
scales = list(alternating = T,
x = list(relation = "free"),
y = list(relation = "same")),
xlab = "Explanatory Variables",
par.strip.text = list(cex = 0.8),
ylab = "Canopy Index",
panel=function(x, y, subscripts,...){
panel.grid(h =- 1, v = 2)
panel.points(x, y, col = "blue", pch = 19)
if(ID10[subscripts][1] != "Minutes.After.Sunset"){panel.loess(x, y, col="red", lwd=2)}
})
XY绘图