An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20091122/ca17457e/attachment-0001.pl>
On 22/11/2009 11:27 AM, Rofizah Mohammad wrote:> Hi, > > If I have 2D data set say (x,y) and I can do scatter plot by using plot(x,y) > command. > How can I add in this scatter plot the equations curve say > > 2X2 + 3Y2 ? 6X ? 7Y + 9 = 0.You could do it using contour(), but you should use an equation that has some real solutions. For example, using a different equation than yours: x <- rnorm(100, sd=1) y <- rnorm(100, sd=1) xgrid <- seq(min(x), max(x), len=100) ygrid <- seq(min(y), max(y), len=120) grid <- expand.grid(x=xgrid, y=ygrid) LHS <- function(x, y) x^2 + y^2 - x - y - 1 z <- apply(grid, 1, function(x) LHS(x[1], x[2]) ) z <- matrix(z, 100, 120) plot(x,y) contour(xgrid, ygrid, z, levels=0, add=TRUE)
On Nov 22, 2009, at 11:27 AM, Rofizah Mohammad wrote:> Hi, > > If I have 2D data set say (x,y) and I can do scatter plot by using > plot(x,y) > command. > How can I add in this scatter plot the equations curve say > > 2X2 + 3Y2 ? 6X ? 7Y + 9 = 0. >No executable example... so if you are too lazy to construct one, then I would suggest looking for worked examples at one of the graphics galleries. Perhaps: http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=44> Regards > > Rofizah > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius, MD Heritage Laboratories West Hartford, CT