Per the example in the kernlab documentation, plot makes a nice figure of the decision weights and boundary of an SVM model.
require(kernlab)
x<- rbind(matrix(rnorm(n=120,mean=-1,sd=2),,2),matrix(rnorm(120,mean=3,sd=2),,2))
y <- matrix(c(rep(1,60),rep(-1,60)))
svp <- ksvm(x,y,type="C-svc",kernel="vanilladot")
plot(svp,data=x)
However, I'd like to change the default colors of the background gradient. Any suggestions how to do this? I've looked into edit(plot), but am not comfortable enough with generic functions to know what to change. Thanks!
If you check with
showMethods("plot")
and thengetMethod("plot", c("ksvm", "missing"))
, you'll see that the plotting function creates its own colors:and uses them for plotting:
which means that you cannot change the colors easily, they are hardcoded into the
ksvm
plot()
.What you can do is
plot()
function, and rewrite it, such that you can overwrite the default colors.