Hi, Do you mean something like this? ============================================= scatter.smooth(x,y)scatter.smooth(x,y) ============================================= It looks like invoking that dcols <- densCols(x,y) is callling in some package that is masking the basic::smoothScatter() and applying some other version of smoothScatter, but I am not expert enough to be sure. Another way to get the same result as mine with smoothScatter is to use the ggplot2 package. it looks a bit more complicated but it is very good and in some ways easier to see exactly what is happening. To try it you would need to install the ggplot2 package (install.packages("ggplot2") then with your original x and y data frames =============================================== library(ggplot2) xy <- cbind(x, y) names(xy) <- c("xx", "yy") p <- ggplot(xy , aes(xx, yy )) + geom_point( ) + geom_smooth( method="loess", se =FALSE) p ================================================ Thanks for the data set. However it really is easier to use dput() To use dput() simply issue the command dput(myfile) where myfile is the file you are working with. It will give you something like this: ====================================================== 1> dput(x) structure(c(0.4543462924, 0.2671718761, 0.1641577016, 1.1593356462, 0.0421177346, 0.3127782861, 0.4515537795, 0.5332559665, 0.0913911528, 0.1472054054, 0.1340672893, 1.2599304224, 0.3872026125, 0.0368560053, 0.0371828779, 0.3999714282, 0.0175815783, 0.8871547761, 0.2706762487, 0.7401904063, 0.0991320236, 0.2565567348, 0.5854167363, 0.7515717421, 0.7220388222, 1.3528297744, 0.9339971349, 0.0128652431, 0.4102527051 ), .Dim = c(29L, 1L), .Dimnames = list(NULL, "V1")) 1> dput(y) structure(list(V1 = c(0.8669898448, 0.6698647266, 0.1641577016, 0.4779091929, 0.2109900366, 0.2915241414, 0.2363116664, 0.3808731568, 0.379908928, 0.2565868263, 0.1986675964, 0.7589866876, 0.6496236922, 0.1327986663, 0.4196107999, 0.3436442638, 0.1910728051, 0.5625817464, 0.1429791079, 0.6441837334, 0.1477153617, 0.369079266, 0.3839842979, 0.39044223, 0.4186374286, 0.7611640016, 0.446291999, 0.2943343355, 0.3019098386)), .Names = "V1", class = "data.frame", row.names = c(NA, -29L)) 1> ======================================================= That is your x in dput() form. You just copy it from the R terminal and paste it into your email message. It is handy if you add the x <- and y <- to the output. Your method works just fine but it's a bit more cumbersome with a lot of data. Also, please reply to the R-help list as well. It is a source of much more expertise than me and it also can reply when a single person is unavailable. I hope this helps John Kane Kingston ON Canada
-----Original Message----- From: zhyjiang2...@hotmail.com Sent: Thu, 4 Oct 2012 05:19:14 +0800 To: jrkrid...@inbox.com Subject: RE: [R] smoothScatter plot Hi John, Thanks for your reply. But I cannot figure out how to use dput(). I included data and code below. Is that possible to make a plot similar to attached smoothing effect. Zhengyu ########### x<-read.table(text="0.4543462924 0.2671718761 0.1641577016 1.1593356462 0.0421177346 0.3127782861 0.4515537795 0.5332559665 0.0913911528 0.1472054054 0.1340672893 1.2599304224 0.3872026125 0.0368560053 0.0371828779 0.3999714282 0.0175815783 0.8871547761 0.2706762487 0.7401904063 0.0991320236 0.2565567348 0.5854167363 0.7515717421 0.7220388222 1.3528297744 0.9339971349 0.0128652431 0.4102527051",header=FALSE) y<-read.table(text="0.8669898448 0.6698647266 0.1641577016 0.4779091929 0.2109900366 0.2915241414 0.2363116664 0.3808731568 0.379908928 0.2565868263 0.1986675964 0.7589866876 0.6496236922 0.1327986663 0.4196107999 0.3436442638 0.1910728051 0.5625817464 0.1429791079 0.6441837334 0.1477153617 0.369079266 0.3839842979 0.39044223 0.4186374286 0.7611640016 0.446291999 0.2943343355 0.3019098386",header=FALSE) x<-data.matrix(x) y<-data.matrix(y) dcols <- densCols(x,y) smoothScatter(x,y, col = dcols, pch=20,xlab="A",ylab="B") ################################ > Date: Tue, 2 Oct 2012 05:19:27 -0800 > From: jrkrid...@inbox.com > Subject: RE: [R] smoothScatter plot > To: zhyjiang2...@hotmail.com; r-help@r-project.org > > It's hard to know what's wrong with your code since you did not supply it. > > Please supply a small working example and some data. To supply data use the dput() function, see ?dput() for details. > > John Kane > Kingston ON Canada > > > > -----Original Message----- > > From: zhyjiang2...@hotmail.com > > Sent: Tue, 2 Oct 2012 11:38:31 +0800 > > To: r-help@r-project.org > > Subject: [R] smoothScatter plot > > > > > > > > > > > > Hi, I want to make a plot similar to sm1 (attached). The code I tried is: > > dcols <- densCols(x,y) > > smoothScatter(x,y, col = dcols, pch=20,xlab="A",ylab="B") > > abline(h=0, col="red") > > But it turned out to be s1 (attached) with big dots. I was wondering if > > anything wrong with my code. Thanks,Zhengyu > > ______________________________________________ > > R-help@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. > > ____________________________________________________________ > FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! > Visit http://www.inbox.com/photosharing to find out more! > > _________________________________________________________________ Free Online Photosharing - Share your photos online with your friends and family! Visit [1]http://www.inbox.com/photosharing to find out more! References 1. http://www.inbox.com/photosharing ______________________________________________ R-help@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.