2

I am trying to change the default colormap of a contour plot, but I can't figure out how.

This is the code I am using:

library(rsm)

A <- c(-1,+1,-1,+1,-1,+1,-1,+1)
B <- c(-1,-1,+1,+1,-1,-1,+1,+1)
y <- c(26,34,21,29,27,33,20,30)

model <-lm(y ~ A+B)
summary(model)

contour(model, ~A+B, image = TRUE)

The contour plot generates the image below. I would like to change the color map to a color-blind friendly one, as viridis.

Thanks in advance for any help.

enter image description here

Marco Sandri
  • 23,289
  • 7
  • 54
  • 58
Rosane Rech
  • 123
  • 1
  • 5

1 Answers1

1

You can specify a new color palette in rsm::contour.lm using the img.col argument:

library(viridis)
contour(model, ~A+B, image = TRUE, img.col=viridis(50))

enter image description here

Marco Sandri
  • 23,289
  • 7
  • 54
  • 58