Skip to content

how add objects to an svm graphic

1 message · Liaw, Andy

#
You probably won't be able to do that without modifying plot.svm().  It
calls filled.contour() like this:

            filled.contour(xr, yr, matrix(as.numeric(preds), 
                nr = length(xr), byrow = TRUE), plot.axes = {
                axis(1)
                axis(2)
                colors <- as.numeric(model.response(model.frame(x, 
                  data)))
                points(formula, data = data[-x$index, ], col =
colors[-x$index])
                points(formula, data = data[x$index, ], pch = "x", 
                  col = colors[x$index])
            }, levels = 1:(length(unique(as.numeric(preds))) + 
                1), key.axes = axis(4, 1:length(unique(as.numeric(preds))) +

                0.5, labels = levels(preds)[unique(preds)], las = 3), 
                plot.title = title(main = "SVM classification plot", 
                  xlab = names(lis)[2], ylab = names(lis)[1]), 
                ...)
      

Note the elaborate `plot.axes=' argument.  You can try add another argument
to plot.svm, which takes an plotting expression, then plug that expression
to the end of the `plot.axes=' expression shown above.

[Note to David:  There's a typo in ?plot.svm (spelling for `vector').]

HTH,
Andy