Hello all. I'm confused a bit about contour plots. After reading the help at "?contour", it seems as though the contour plot is for 3D plots (x,y, and z). My data is in the form of grid coordinates (x,y), and I want to see a contour plot of the data so that I can tell where most observations lie. My question is simple but still evasive. Say my data is called places. One column is X and another is Y. Or, places$X places$Y Coordinate 1 32 50 Coordinate 2 15 33 Coordinate 3 28 20 etc How do I get R to do the contour plot with no third "z" coordinate? Thanks. -- Do all you can with what you have in the time you have in the place you are! -Nkosi Johnson, 12-year old African hero
I guess what you want is contours of the density over the x-y plane. There are a few choices that I know of: kde2d in MASS (part of the `VR' bundle) bkde2d in KernSmooth sm.density in sm locfit in locfit Andy> From: Bernard L. Dillard > > Hello all. > > I'm confused a bit about contour plots. After reading the help at > "?contour", it seems as though the contour plot is for 3D > plots (x,y, and > z). My data is in the form of grid coordinates (x,y), and I > want to see a > contour plot of the data so that I can tell where most > observations lie. > My question is simple but still evasive. > > Say my data is called places. One column is X and another is Y. Or, > > places$X places$Y > > Coordinate 1 32 50 > Coordinate 2 15 33 > Coordinate 3 28 20 > etc > > How do I get R to do the contour plot with no third "z" coordinate? > > Thanks. > > -- > Do all you can with what you have in the time you have in the > place you are! > > -Nkosi Johnson, 12-year old African hero > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > >
Bernard L. Dillard wrote:> Hello all. > > I'm confused a bit about contour plots. After reading the help at > "?contour", it seems as though the contour plot is for 3D plots (x,y, and > z). My data is in the form of grid coordinates (x,y), and I want to see a > contour plot of the data so that I can tell where most observations lie. > My question is simple but still evasive. > > Say my data is called places. One column is X and another is Y. Or, > > places$X places$Y > > Coordinate 1 32 50 > Coordinate 2 15 33 > Coordinate 3 28 20 > etc > > How do I get R to do the contour plot with no third "z" coordinate?For just 2 columns, a contour plot does not make much sense, I guess. I think an image() makes much more sense in this case. Your z matrix consists of the entries of the data.frame/matrix given above, the x and y vectors are the column and row numbers. Uwe Ligges> Thanks. >