0
votes

This is probably a very basic question, but I am struggling to change the graphics parameters in the xyplot (below). The objective is to change the colour of the regression line to red and the data-points to blue.

I have basicaly tried the code below but when I add pch=19, and col="blue" to the code the colours don't change.

If anyone can help, I would be deeply appreciative.

R code for the XY plot

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

enter image description here

1
I see that you have panel.points(x, y, col = 1, pch = 16) and panel.loess(x,y,col=1,lwd=2) in your sample code. Did you change the color there? col=1 specifies black. Similarly, you specify pch=16 there. Is that where you tried pch=19?G5W
Thanks for replying G5W, the code was written by a colleague hence my confusion where to change the code for the desired result. I followed your advice and changing the graphics parameters worked. The answer is below :)Alice Hobbs

1 Answers

1
votes

Heres the answer:

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

enter image description here