RE: [R] how add objects to an svm graphic

About this list Date view Thread view Subject view Author view Attachment view

From: Liaw, Andy (andy_liaw@merck.com)
Date: Fri 14 May 2004 - 22:39:42 EST


Message-id: <3A822319EB35174CA3714066D590DCD504AF7D99@usrymx25.merck.com>

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

> From: ale.ambrosi@unipd.it
>
> Dear all,
>
> I'm not able to solve easily the following simple problem.
> I really hope someone can give me some hints.
>
> I trained an svm (e1071). Now I'd like to show the results
> graphically.
> I used plot.svm and I'd like to add some other objects to the plot:
> points, (coloured) ellipses to indicate some intersting
> regions, curves,
> and so on...
> I tried to pass these as additional graphics parameters to pass to
> filled.contour, as indicated in ?plot.svm and in examples in
> filled.contour help.
>
> But it doesn't seem to work.
>
> Where is my foult? Can anyone help me?
>
> Best,
> Alessandro
>
>
> PS: I use R 1.9.0 on a WinXP OS
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Alessandro Ambrosi, Ph.D. |
> Oncological Surgical Sc. Dept. | mail: ale.ambrosi@unipd.it
> Surg. Cl. II | ambrosi@stat.unipd.it
> University of Padua | fax: +39 049 651891
> via Giustiniani, 2 | tel: +39 049 8212055
> I-35128 Padua (ITALY) | url:
> www.stat.unipd.it/~ambrosi
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
> -------------------------------------------------
> This mail sent through IMP: webmail.unipd.it
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:10 EST