Hi Listers, Is it possible to produce an ordination plot in 2d, where bubbles represent the location of sites (this part is easy enough) and the size of the bubbles is proportional to the sites location in 3d space (I am stuck on this option). So sites that are very near the 2d plane of the xy axes would be larger while sites that are actually further away in 3 d space would be proportionally smaller. any help/advice appreciated Andy -- Andrew Halford Ph.D Associate Research Scientist Marine Laboratory University of Guam Ph: +1 671 734 2948 [[alternative HTML version deleted]]
On 08/10/2011 10:02 AM, Andrew Halford wrote:> Hi Listers, > > Is it possible to produce an ordination plot in 2d, where bubbles represent > the location of sites (this part is easy enough) and the size of the bubbles > is proportional to the sites location in 3d space (I am stuck on this > option). So sites that are very near the 2d plane of the xy axes would be > larger while sites that are actually further away in 3 d space would be > proportionally smaller. > > any help/advice appreciated > > Andy >Hi Andy! I think ggplot2 would be the package I would use to do this kind of plots. However, without "commented, minimal, self-contained, reproducible code" I cannot provide an example of how to do it. cheers, Paul -- Paul Hiemstra, Ph.D. Global Climate Division Royal Netherlands Meteorological Institute (KNMI) Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39 P.O. Box 201 | 3730 AE | De Bilt tel: +31 30 2206 494 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
Very easy if you note that cex in plot can be a vector. example: x <- runif(100) y<-runif(100) z<-runif(100) #shift and scale z for convenience 9the scaling is based on range 'cos we know this is in [0,1] #your mileage may vary but the principle is ) z.scaled <- 0.05 + (z-min(z))/diff(range(z)) plot(x, y, cex=2*z.scaled) #Symbol size increases linearly with z You can add a key by giving legend() a list of three or four cex values and corresponding distances in z, if yo like. But ggplot (as a previous poster indicated) is also a natural way to do this, and adds a nice key for you if you map a variable to an aesthetic.> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of Andrew Halford > Sent: 10 August 2011 11:03 > To: r-help at r-project.org > Subject: [R] plot 3d info in 2d > > Hi Listers, > > Is it possible to produce an ordination plot in 2d, where > bubbles represent the location of sites (this part is easy > enough) and the size of the bubbles is proportional to the > sites location in 3d space (I am stuck on this option). So > sites that are very near the 2d plane of the xy axes would be > larger while sites that are actually further away in 3 d > space would be proportionally smaller. > > any help/advice appreciated > > Andy > > -- > Andrew Halford Ph.D > Associate Research Scientist > Marine Laboratory > University of Guam > Ph: +1 671 734 2948 > > [[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. > *******************************************************************This email and any attachments are confidential. Any use...{{dropped:8}}
On 08/10/2011 10:02 AM, Andrew Halford wrote:> Hi Listers, > > Is it possible to produce an ordination plot in 2d, where bubbles represent > the location of sites (this part is easy enough) and the size of the bubbles > is proportional to the sites location in 3d space (I am stuck on this > option). So sites that are very near the 2d plane of the xy axes would be > larger while sites that are actually further away in 3 d space would be > proportionally smaller. > > any help/advice appreciated > > Andy >Plotting the dataset which was proposed by S. Ellison using ggplot2 is done in this fashion: library(ggplot2) theme_set(theme_bw()) dat = data.frame(x <- runif(100), y<-runif(100), z<-runif(100)) ggplot(aes(x = x, y = y, size = z), data = dat) + geom_point(color 'lightblue') # Using log(z) in stead of z ggplot(aes(x = x, y = y, size = z), data = dat) + geom_point(color 'lightblue') + scale_size_continuous(trans = 'log') # Alternatively, making the color of the point dependend on the value of z ggplot(aes(x = x, y = y, color = z), data = dat) + geom_point(size = 6) + scale_color_gradient(low = 'white', high = 'blue') cheers, Paul -- Paul Hiemstra, Ph.D. Global Climate Division Royal Netherlands Meteorological Institute (KNMI) Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39 P.O. Box 201 | 3730 AE | De Bilt tel: +31 30 2206 494 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770