[R] How to interpret and modify "plot.svm"?

David Meyer david.meyer at wu-wien.ac.at
Fri Dec 17 18:46:07 CET 2004


> Dear R people,

> I am trying to plot the results from running svm in library(e1071). I
> use plot.svm. After searching through the help archives and FAQ, I
> still have several questions:

> 1.  In default, crosses indicate support vectors. But why are there
> two colors of crosses? What do they represent?

The colors represent the classes of the data points. The help page
admittedly doesn't tell you this and deserves improvement.

> 2. I want to draw a white-gray colored plot and modify the different
> colored crosses or circles by different shaped points. Could anyone
> give me a hint?

I just added three arguments to plot.svm() that allow customizing of the
plot symbols. The contour region is controlled by the parameters of the
filled.contour() function used in plot.svm(), so you will need to add
the color.palette argument to plot.svm (which subsequently will be
passed to filled.contour()).

> 3. Is it possible for me to draw a "hyperplane" on the plot?

You can add arbitrary objects to the plot (try lines()); but plot.svm()
doesn't compute the boundaries.

> 4. What is the algorithm to plot the contour region?

see filled.contour(). The input is determined by a grid of predicted


> Thank you very much,

> Frank

Dr. David Meyer
Department of Information Systems

Vienna University of Economics and Business Administration
Augasse 2-6, A-1090 Wien, Austria, Europe
Fax: +43-1-313 36x746 
Tel: +43-1-313 36x4393
HP:  http://wi.wu-wien.ac.at/~meyer/

More information about the R-help mailing list