Hi all, I'm fairly new to R, so I'm still trying to feel out what is available to me. I would like to be able to plot joint density in a two dimensional plot where density is indicated by color or darkness gradients, like a 2d color coded topographic map. Ideally, the output would be something I could then plot other points or lines on. Currently, I'm calculating joint density with the function kde2d(), and plotted with persp(). Thanks a bunch. -Joe [[alternative HTML version deleted]]
Look at "levelplot" in the lattice package. On Nov 26, 2007 5:19 PM, Josef Fruehwald <jofrhwld at gmail.com> wrote:> Hi all, > > I'm fairly new to R, so I'm still trying to feel out what is available to > me. I would like to be able to plot joint density in a two dimensional plot > where density is indicated by color or darkness gradients, like a 2d color > coded topographic map. Ideally, the output would be something I could then > plot other points or lines on. > > Currently, I'm calculating joint density with the function kde2d(), and > plotted with persp(). > > Thanks a bunch. > > -Joe > > [[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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?
On Mon, 26 Nov 2007, Josef Fruehwald wrote:> Hi all, > > I'm fairly new to R, so I'm still trying to feel out what is available to > me. I would like to be able to plot joint density in a two dimensional plot > where density is indicated by color or darkness gradients, like a 2d color > coded topographic map. Ideally, the output would be something I could then > plot other points or lines on. > > Currently, I'm calculating joint density with the function kde2d(), and > plotted with persp().You can use image() (as done on ?kde2d) or filled.contour(). Following the example on ?kde2d, you could do f1 <- kde2d(geyser$duration, geyser$waiting, n = 50, lims = c(0.5, 6, 40, 100)) filled.contour(f1, col = rev(grey.colors(33)), nlevels = 33) If you don't want a grayscale palette but something with color, you could look at heat_hcl() in package "vcd" and the accompanying vignette vignette("hcl-colors", package = "vcd") which also has some 2D density examples based on the geyser data. Z> Thanks a bunch. > > -Joe > > [[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. > >