Skip to content

3d density plot

3 messages · Nabeil Salama, Kingsford Jones, ONKELINX, Thierry

#
Hi Nabeil,

I'm not sure I understand what you'd like to accomplish, but perhaps
the following will be helpful:

example(kde2d, package='MASS')


hth,

Kingsford Jones
On Fri, Jun 19, 2009 at 10:32 AM, Nabeil Salama<N.Salama at marlab.ac.uk> wrote:
1 day later
#
Here is a solution using ggplot2 

Positions <- expand.grid(Run = seq_len(100), ID = seq_len(101))
Positions$X <- runif(nrow(Positions), -.5, .5)
Positions$Y <- runif(nrow(Positions), -.5, .5)
Positions[Positions$ID == 1, c("X", "Y")] <- Positions[Positions$ID == 1, c("X", "Y")] + matrix(c(50, 40), ncol = 2, nrow = 100, byrow = TRUE)
library(plyr)
Positions <- ddply(Positions, "Run", function(x){
	x <- x[order(x$ID), ]
	x$X <- cumsum(x$X)
	x$Y <- cumsum(x$Y)
	x
})
library(ggplot2)
ggplot(Positions, aes(x = X, y = Y)) + geom_density2d()

HTH,

Thierry


----------------------------------------------------------------------------
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
Thierry.Onkelinx at inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

-----Oorspronkelijk bericht-----
Van: r-sig-ecology-bounces at r-project.org [mailto:r-sig-ecology-bounces at r-project.org] Namens Kingsford Jones
Verzonden: zaterdag 20 juni 2009 0:05
Aan: Nabeil Salama
CC: r-sig-ecology at r-project.org
Onderwerp: Re: [R-sig-eco] 3d density plot

Hi Nabeil,

I'm not sure I understand what you'd like to accomplish, but perhaps the following will be helpful:

example(kde2d, package='MASS')


hth,

Kingsford Jones
On Fri, Jun 19, 2009 at 10:32 AM, Nabeil Salama<N.Salama at marlab.ac.uk> wrote:
_______________________________________________
R-sig-ecology mailing list
R-sig-ecology at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.