[R] plot 3d info in 2d

Paul Hiemstra paul.hiemstra at knmi.nl
Wed Aug 10 13:12:31 CEST 2011


 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



More information about the R-help mailing list