Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
Gray writes: > I have a scatterplot with a bunch of points on it. I'd like to plot > isodensity contours to include 99%, 90%, 75%, and 50% of my points. > How do I set up my data to give to cgContour? Thanks! The simple answer is, you set up your data the way you *always* set up your data! Don't you really want to know, how do I choose some percentage of my points? And, that question we can't answer, because you haven't indicated what the criteria are going to be. I guess you will have to decide. Randomly, distance from the centroid, based on height above surface, etc. Lot's of possibilities here. Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting, Inc. Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ Sepore ma de ni thui. ("Perhaps thou speakest truth.")
On Feb 23, 1:24 pm, Gray <grayliketheco...@gmail.com> wrote: > Hi all, > > I have a scatterplot with a bunch of points on it. I'd like to plot > isodensity contours to include 99%, 90%, 75%, and 50% of my points. > How do I set up my data to give to cgContour? Thanks! > > --Gray If I understand this correctly, you have two arrays x and y of coordinates of N points. To contour them, you need first to create a density array from your dataset - basically you divide the xrange and yrange of your data in a number of bins and the density array will tell you how many points lie in each bin. Then you can use the normal contour procedures. So how you do partition the data into the density array? hist_2d will do that for you. Ciao, Paolo
On Wednesday, February 23, 2011 1:24:30 PM UTC-5, Gray wrote: > Hi all, > > I have a scatterplot with a bunch of points on it. I'd like to plot > isodensity contours to include 99%, 90%, 75%, and 50% of my points. > How do I set up my data to give to cgContour? Thanks! > > --Gray You may find contourlevels in JBIU useful: http://web.astroconst.org/jbiu/jbiu-doc/misc/contourlevels.h tml -Jeremy.
On Feb 23, 2:12 pm, Paolo <pgri...@gmail.com> wrote: > On Feb 23, 1:24 pm, Gray <grayliketheco...@gmail.com> wrote: > >> Hi all, > >> I have a scatterplot with a bunch of points on it. I'd like to plot >> isodensity contours to include 99%, 90%, 75%, and 50% of my points. >> How do I set up my data to give to cgContour? Thanks! > >> --Gray > > If I understand this correctly, you have two arrays > x and y of coordinates of N points. > > To contour them, you need first to create a > density array from your dataset - basically > you divide the xrange and yrange of your data > in a number of bins and the density array will > tell you how many points lie in each bin. > > Then you can use the normal contour procedures. > > So how you do partition the data into the density > array? hist_2d will do that for you. > > Ciao, > Paolo I thought I posted this already... if it shows up twice, I'm sorry. Upon further reflection, I think that "isodensity contours" are not exactly what I want, though I may need to use them anyway (as described by Paolo) if I can't figure out a way to do EXACTLY what I want. Here's some more detail on my issue. I have a plot for which the x- axis is stellar magnitude in one image, and the y-axis is stellar magnitude in a different image. I have two populations of stars (pop A and pop B). Pop A is pretty clustered, but the cluster is sort of smeared out so I can't use a simple centroid. I'd like to see where the pop B stars lay on the plot in relation to the pop A stars by plotting contours showing what percentage of pop A stars are within them (99%,90%,75%,50%). Is this doable without getting really complicated, or should I use the isodensity contours instead? An example image is at http://tinypic.com/r/2mepz4/7 The black points are pop A and the colored symbols are pop B. Thanks for your help! --Gray
On Feb 23, 3:06 pm, Gray <grayliketheco...@gmail.com> wrote: > On Feb 23, 2:12 pm, Paolo <pgri...@gmail.com> wrote: > > > > > > > > > >> On Feb 23, 1:24 pm, Gray <grayliketheco...@gmail.com> wrote: > >>> Hi all, > >>> I have a scatterplot with a bunch of points on it. I'd like to plot >>> isodensity contours to include 99%, 90%, 75%, and 50% of my points. >>> How do I set up my data to give to cgContour? Thanks! > >>> --Gray > >> If I understand this correctly, you have two arrays >> x and y of coordinates of N points. > >> To contour them, you need first to create a >> density array from your dataset - basically >> you divide the xrange and yrange of your data >> in a number of bins and the density array will >> tell you how many points lie in each bin. > >> Then you can use the normal contour procedures. > >> So how you do partition the data into the density >> array? hist_2d will do that for you. > >> Ciao, >> Paolo > > I thought I posted this already... if it shows up twice, I'm sorry. > > Upon further reflection, I think that "isodensity contours" are not > exactly what I want, though I may need to use them anyway (as > described by Paolo) if I can't figure out a way to do EXACTLY what I > want. > > Here's some more detail on my issue. I have a plot for which the x- > axis is stellar magnitude in one image, and the y-axis is stellar > magnitude in a different image. I have two populations of stars (pop > A and pop B). Pop A is pretty clustered, but the cluster is sort of > smeared out so I can't use a simple centroid. I'd like to see where > the pop B stars lay on the plot in relation to the pop A stars by > plotting contours showing what percentage of pop A stars are within > them (99%,90%,75%,50%). Is this doable without getting really > complicated, or should I use the isodensity contours instead? > > An example image is athttp://tinypic.com/r/2mepz4/7 > The black points are pop A and the colored symbols are pop B. > > Thanks for your help! > > --Gray I would at least try to get the density for the pop A stars - will take only a few minutes to do. You may want to smooth the contours a bit. But it looks like it should come out reasonably well... Ciao, Paolo
On Feb 23, 3:04 pm, Jeremy Bailin <astroco...@gmail.com> wrote: > On Wednesday, February 23, 2011 1:24:30 PM UTC-5, Gray wrote: >> Hi all, > >> I have a scatterplot with a bunch of points on it. I'd like to plot >> isodensity contours to include 99%, 90%, 75%, and 50% of my points. >> How do I set up my data to give to cgContour? Thanks! > >> --Gray > > You may find contourlevels in JBIU useful: > > http://web.astroconst.org/jbiu/jbiu-doc/misc/contourlevels.h tml > > -Jeremy. Oh, perfect! Thank you!
On Feb 23, 3:24 pm, Paolo <pgri...@gmail.com> wrote: > On Feb 23, 3:06 pm, Gray <grayliketheco...@gmail.com> wrote: > > > > > > > > > >> On Feb 23, 2:12 pm, Paolo <pgri...@gmail.com> wrote: > >>> On Feb 23, 1:24 pm, Gray <grayliketheco...@gmail.com> wrote: > >>>> Hi all, > >>>> I have a scatterplot with a bunch of points on it. I'd like to plot >>>> isodensity contours to include 99%, 90%, 75%, and 50% of my points. >>>> How do I set up my data to give to cgContour? Thanks! > >>>> --Gray > >>> If I understand this correctly, you have two arrays >>> x and y of coordinates of N points. > >>> To contour them, you need first to create a >>> density array from your dataset - basically >>> you divide the xrange and yrange of your data >>> in a number of bins and the density array will >>> tell you how many points lie in each bin. > >>> Then you can use the normal contour procedures. > >>> So how you do partition the data into the density >>> array? hist_2d will do that for you. > >>> Ciao, >>> Paolo > >> I thought I posted this already... if it shows up twice, I'm sorry. > >> Upon further reflection, I think that "isodensity contours" are not >> exactly what I want, though I may need to use them anyway (as >> described by Paolo) if I can't figure out a way to do EXACTLY what I >> want. > >> Here's some more detail on my issue. I have a plot for which the x- >> axis is stellar magnitude in one image, and the y-axis is stellar >> magnitude in a different image. I have two populations of stars (pop >> A and pop B). Pop A is pretty clustered, but the cluster is sort of >> smeared out so I can't use a simple centroid. I'd like to see where >> the pop B stars lay on the plot in relation to the pop A stars by >> plotting contours showing what percentage of pop A stars are within >> them (99%,90%,75%,50%). Is this doable without getting really >> complicated, or should I use the isodensity contours instead? > >> An example image is athttp://tinypic.com/r/2mepz4/7 >> The black points are pop A and the colored symbols are pop B. > >> Thanks for your help! > >> --Gray > > I would at least try to get the density for the pop A > stars - will take only a few minutes to do. You may want > to smooth the contours a bit. But it looks like it should > come out reasonably well... > > Ciao, > Paolo How does one smooth contours? :/
On Feb 23, 1:39 pm, David Fanning <n...@idlcoyote.com> wrote: > Gray writes: >> I have a scatterplot with a bunch of points on it. I'd like to plot >> isodensity contours to include 99%, 90%, 75%, and 50% of my points. >> How do I set up my data to give to cgContour? Thanks! > > The simple answer is, you set up your data the way > you *always* set up your data! > > Don't you really want to know, how do I choose > some percentage of my points? And, that question > we can't answer, because you haven't indicated > what the criteria are going to be. I guess > you will have to decide. Randomly, distance > from the centroid, based on height above surface, > etc. Lot's of possibilities here. > > Cheers, > > David > > -- > David Fanning, Ph.D. > Fanning Software Consulting, Inc. > Coyote's Guide to IDL Programming:http://www.idlcoyote.com/ > Sepore ma de ni thui. ("Perhaps thou speakest truth.") David - When I actually try to plot the contour, it doesn't work. My x and y inputs to cgContour are xb and yb: IDL> print, minmax(xb), minmax(yb) 5.92672 20.6767 -9.38564 7.11436 Why does the contour plot out in space? http://tinypic.com/r/2viio7l/7
Gray writes: > When I actually try to plot the contour, it doesn't work. My x and y > inputs to cgContour are xb and yb: > IDL> print, minmax(xb), minmax(yb) > 5.92672 20.6767 > -9.38564 7.11436 > > Why does the contour plot out in space? http://tinypic.com/r/2viio7l/7 Are you setting the OVERPLOT keyword, so that it plots onto the axes that are already established? Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting, Inc. Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ Sepore ma de ni thui. ("Perhaps thou speakest truth.")
On Feb 23, 8:43 pm, David Fanning <n...@idlcoyote.com> wrote: > Gray writes: >> When I actually try to plot the contour, it doesn't work. My x and y >> inputs to cgContour are xb and yb: >> IDL> print, minmax(xb), minmax(yb) >> 5.92672 20.6767 >> -9.38564 7.11436 > >> Why does the contour plot out in space? http://tinypic.com/r/2viio7l/7 > > Are you setting the OVERPLOT keyword, so that it > plots onto the axes that are already established? > > Cheers, > > David > > -- > David Fanning, Ph.D. > Fanning Software Consulting, Inc. > Coyote's Guide to IDL Programming:http://www.idlcoyote.com/ > Sepore ma de ni thui. ("Perhaps thou speakest truth.") Yes. Here's my cgContour call: cgcontour, contour_in, xb, yb, /overplot, levels=lev, label=0
Gray writes: > Yes. Here's my cgContour call: > cgcontour, contour_in, xb, yb, /overplot, levels=lev, label=0 Well, I don't know. Maybe it's doing the right thing. :-) What does the contour plot look like by itself? Do you get the same thing when you use the Contour command? I'm off to play tennis tonight, but if you want to send me a save file with the data, maybe I can look at it later. Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting, Inc. Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ Sepore ma de ni thui. ("Perhaps thou speakest truth.")
On Feb 23, 7:34 pm, Gray <grayliketheco...@gmail.com> wrote: > On Feb 23, 3:24 pm, Paolo <pgri...@gmail.com> wrote: > > > > > > > > > >> On Feb 23, 3:06 pm, Gray <grayliketheco...@gmail.com> wrote: > >>> On Feb 23, 2:12 pm, Paolo <pgri...@gmail.com> wrote: > >>>> On Feb 23, 1:24 pm, Gray <grayliketheco...@gmail.com> wrote: > >>>> > Hi all, > >>>> > I have a scatterplot with a bunch of points on it. I'd like to plot >>>> > isodensity contours to include 99%, 90%, 75%, and 50% of my points. >>>> > How do I set up my data to give to cgContour? Thanks! > >>>> > --Gray > >>>> If I understand this correctly, you have two arrays >>>> x and y of coordinates of N points. > >>>> To contour them, you need first to create a >>>> density array from your dataset - basically >>>> you divide the xrange and yrange of your data >>>> in a number of bins and the density array will >>>> tell you how many points lie in each bin. > >>>> Then you can use the normal contour procedures. > >>>> So how you do partition the data into the density >>>> array? hist_2d will do that for you. > >>>> Ciao, >>>> Paolo > >>> I thought I posted this already... if it shows up twice, I'm sorry. > >>> Upon further reflection, I think that "isodensity contours" are not >>> exactly what I want, though I may need to use them anyway (as >>> described by Paolo) if I can't figure out a way to do EXACTLY what I >>> want. > >>> Here's some more detail on my issue. I have a plot for which the x- >>> axis is stellar magnitude in one image, and the y-axis is stellar >>> magnitude in a different image. I have two populations of stars (pop >>> A and pop B). Pop A is pretty clustered, but the cluster is sort of >>> smeared out so I can't use a simple centroid. I'd like to see where >>> the pop B stars lay on the plot in relation to the pop A stars by >>> plotting contours showing what percentage of pop A stars are within >>> them (99%,90%,75%,50%). Is this doable without getting really >>> complicated, or should I use the isodensity contours instead? > >>> An example image is athttp://tinypic.com/r/2mepz4/7 >>> The black points are pop A and the colored symbols are pop B. > >>> Thanks for your help! > >>> --Gray > >> I would at least try to get the density for the pop A >> stars - will take only a few minutes to do. You may want >> to smooth the contours a bit. But it looks like it should >> come out reasonably well... > >> Ciao, >> Paolo > > How does one smooth contours? :/ IDL has a builtin function called min_curve_surf It's a bit slow though - use it on small arrays Ciao, Paolo