comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Contour Plot Issues
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Contour Plot Issues [message #80818] Fri, 13 July 2012 17:17
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
ecatcom1@gmail.com writes:

> Yep, it's exactly what I wanted.
> And your code works for me, too.
> I stripped my cgContour command down to the bare minimum and it worked(just the data, ranges, and aspect). Then started adding the extra stuff, and it worked fine until the /Window keyboard. Seems that's what is making my plot go crazy. Any reason why this should be? I added it to the code you posted, also, and /Window causes issues with that too.

Ah, yes, I've seen that problem before!

I think Coyote must have taken me out and got me
liquored up the night I got the big idea to separate
cgWindow from cgCmdWindow. Because I had a very nice
working program one day, and something else the
next, and can't really remember how it happened. :-(

Anyway, cgWindow *should* be using the WASPECT
keyword to set the window aspect ratio, but somehow
it got turned around to think it should be using
the ASPECT keyword to do this. Naturally, we are
running in to problems with this now.

So, I've gone back to the WASPECT keyword for
setting Window ASPECT, like it should have been
all the time.

You can download the correct programs here:

http://www.idlcoyote.com/programs/cgwindow.pro
http://www.idlcoyote.com/programs/cgcmdwindow__define.pro

Sorry for the inconvenience. I'm going to go have it
out with Coyote now, if I can find him. He leaves about
2:00 in the afternoon on Fridays to start partying.
Sometimes I don't see him until noon on Monday. :-(

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.")
Re: Contour Plot Issues [message #80819 is a reply to message #80818] Fri, 13 July 2012 14:57 Go to previous message
Oana Coman is currently offline  Oana Coman
Messages: 27
Registered: December 2011
Junior Member
Yep, it's exactly what I wanted.
And your code works for me, too.
I stripped my cgContour command down to the bare minimum and it worked(just the data, ranges, and aspect). Then started adding the extra stuff, and it worked fine until the /Window keyboard. Seems that's what is making my plot go crazy. Any reason why this should be? I added it to the code you posted, also, and /Window causes issues with that too.

On Friday, July 13, 2012 2:11:16 PM UTC-7, David Fanning wrote:
> ecatcom1@gmail.com writes:
>
> > Whoops! Light bulb just turned on!
> > New Code:
> > xrange=[xmin,xmax]
> > yrange=[ymin,ymax]
> >
> > numLevels=size(levels)
> > LoadCT, 33, NColorS=numLevels(1), Bottom=1
> > xran=xmax-xmin
> > yran=ymax-ymin
> > asp=yran/xran
> > cgContour,aa,x(ix),y(iy), /Fill,$
> > levels=levels, C_colors=Indgen(numLevels(1))+1,$
> > c_labels=levels, /Outline,$
> > xminor=5, yminor=5,$
> > xrange=xrange, yrange=yrange,$
> > xtickinterval=10, ytickinterval=10,$
> > ASPECT=asp,/Window
> >
> > When I am resizing my window, it keeps the aspect radio the same. Yay!
> > The problem is my plot doesnt show the correct aspect ratio. For example, I just plotted something with x=[-12,11] y=[-34,33], asp=2.91304 (i put a stop in my code and checked to see that all these values are correct and they are). But when it actually plots, the y-axis looks almost 5 times bigger than the x...which is not what I told it to do.
> > Any ideas why this could be happening? Is my code funky?
> >
> > Thanks for putting up with my sillyness!
>
> I don't know. This looks right to me. Here is the code
> I used:
>
> cgcontour, cgdemodata(2), xrange=[-12, 11], $
> yrange=[-34,33], aspect=67./23
>
> The distance from 0 to 10 on the X axis is the same as
> the distance from 0 to 10 on the Y axis. Isn't that
> what you wanted, for the distances to be in the same
> units?
>
> 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.")
Re: Contour Plot Issues [message #80821 is a reply to message #80819] Fri, 13 July 2012 14:11 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
ecatcom1@gmail.com writes:

> Whoops! Light bulb just turned on!
> New Code:
> xrange=[xmin,xmax]
> yrange=[ymin,ymax]
>
> numLevels=size(levels)
> LoadCT, 33, NColorS=numLevels(1), Bottom=1
> xran=xmax-xmin
> yran=ymax-ymin
> asp=yran/xran
> cgContour,aa,x(ix),y(iy), /Fill,$
> levels=levels, C_colors=Indgen(numLevels(1))+1,$
> c_labels=levels, /Outline,$
> xminor=5, yminor=5,$
> xrange=xrange, yrange=yrange,$
> xtickinterval=10, ytickinterval=10,$
> ASPECT=asp,/Window
>
> When I am resizing my window, it keeps the aspect radio the same. Yay!
> The problem is my plot doesnt show the correct aspect ratio. For example, I just plotted something with x=[-12,11] y=[-34,33], asp=2.91304 (i put a stop in my code and checked to see that all these values are correct and they are). But when it actually plots, the y-axis looks almost 5 times bigger than the x...which is not what I told it to do.
> Any ideas why this could be happening? Is my code funky?
>
> Thanks for putting up with my sillyness!

I don't know. This looks right to me. Here is the code
I used:

cgcontour, cgdemodata(2), xrange=[-12, 11], $
yrange=[-34,33], aspect=67./23

The distance from 0 to 10 on the X axis is the same as
the distance from 0 to 10 on the Y axis. Isn't that
what you wanted, for the distances to be in the same
units?

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.")
Re: Contour Plot Issues [message #80826 is a reply to message #80821] Fri, 13 July 2012 13:42 Go to previous message
Oana Coman is currently offline  Oana Coman
Messages: 27
Registered: December 2011
Junior Member
Whoops! Light bulb just turned on!
New Code:
xrange=[xmin,xmax]
yrange=[ymin,ymax]

numLevels=size(levels)
LoadCT, 33, NColorS=numLevels(1), Bottom=1
xran=xmax-xmin
yran=ymax-ymin
asp=yran/xran
cgContour,aa,x(ix),y(iy), /Fill,$
levels=levels, C_colors=Indgen(numLevels(1))+1,$
c_labels=levels, /Outline,$
xminor=5, yminor=5,$
xrange=xrange, yrange=yrange,$
xtickinterval=10, ytickinterval=10,$
ASPECT=asp,/Window

When I am resizing my window, it keeps the aspect radio the same. Yay!
The problem is my plot doesnt show the correct aspect ratio. For example, I just plotted something with x=[-12,11] y=[-34,33], asp=2.91304 (i put a stop in my code and checked to see that all these values are correct and they are). But when it actually plots, the y-axis looks almost 5 times bigger than the x...which is not what I told it to do.
Any ideas why this could be happening? Is my code funky?

Thanks for putting up with my sillyness!

On Friday, July 13, 2012 12:33:57 PM UTC-7, David Fanning wrote:
> ecatcom1@gmail.com writes:
>
> > That's the big problem, though. I don't know ahead of time how my plot is going to look. I am working with someone's GUI. There's an IDL draw widget where I'm defining a region of interest, and depending on that region of interest my program computes an autocorrelation and then plots the results. So the shape of my plot will depend on the shape of the ROI, and since I'm not actually inputting numbers for this ROI but clicking and dragging in that window to create a
> rectangle, I don't have a way of knowing what those dimensions are before the plot (so I can't hardcode an aspect ratio ahead of time).
> > I feel like there has to be some way to define the plot size using the x range and y range that will still give me even tick spacing in both axes, or some way to just make the contour plot have those even tick spacings. I just don't know what it is :(
>
> Well, you can continue to believe this if you like. Good
> luck with this!
>
> But, if you are the one creating the ROI, and you seem to have
> some notion of the xrange and yrange, then I'd be willing to
> bet some money you have enough information to set the aspect
> ratio of the plot correctly. :-)
>
> 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.")
Re: Contour Plot Issues [message #80829 is a reply to message #80826] Fri, 13 July 2012 12:33 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
ecatcom1@gmail.com writes:

> That's the big problem, though. I don't know ahead of time how my plot is going to look. I am working with someone's GUI. There's an IDL draw widget where I'm defining a region of interest, and depending on that region of interest my program computes an autocorrelation and then plots the results. So the shape of my plot will depend on the shape of the ROI, and since I'm not actually inputting numbers for this ROI but clicking and dragging in that window to create a
rectangle, I don't have a way of knowing what those dimensions are before the plot (so I can't hardcode an aspect ratio ahead of time).
> I feel like there has to be some way to define the plot size using the x range and y range that will still give me even tick spacing in both axes, or some way to just make the contour plot have those even tick spacings. I just don't know what it is :(

Well, you can continue to believe this if you like. Good
luck with this!

But, if you are the one creating the ROI, and you seem to have
some notion of the xrange and yrange, then I'd be willing to
bet some money you have enough information to set the aspect
ratio of the plot correctly. :-)

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.")
Re: Contour Plot Issues [message #80830 is a reply to message #80829] Fri, 13 July 2012 12:25 Go to previous message
Oana Coman is currently offline  Oana Coman
Messages: 27
Registered: December 2011
Junior Member
Hi David,
That's the big problem, though. I don't know ahead of time how my plot is going to look. I am working with someone's GUI. There's an IDL draw widget where I'm defining a region of interest, and depending on that region of interest my program computes an autocorrelation and then plots the results. So the shape of my plot will depend on the shape of the ROI, and since I'm not actually inputting numbers for this ROI but clicking and dragging in that window to create a rectangle, I don't have a way of knowing what those dimensions are before the plot (so I can't hardcode an aspect ratio ahead of time).
I feel like there has to be some way to define the plot size using the x range and y range that will still give me even tick spacing in both axes, or some way to just make the contour plot have those even tick spacings. I just don't know what it is :(


On Thursday, July 12, 2012 3:30:50 PM UTC-7, Coyote wrote:
> ecat...@gmail.com writes:
>
> > Does the aspect keyword just keep the aspect ratio of the contour plot the same?
>
> The ASPECT keyword should be used to set the aspect ratio of the plot to whatever aspect it is you want. If you want 5 units in Y and 10 units in X, then the aspect ratio of 5./10. If you have 10 units of Y and 5 units of X, then the aspect ratio you want is 10./5. You will have to decide the aspect ratio based on the X and Y ranges of your plot. In your original post, you had these the same, so I suggested an aspect ratio of 1.0.
>
> Cheers,
>
> David
Re: Contour Plot Issues [message #80840 is a reply to message #80830] Thu, 12 July 2012 15:30 Go to previous message
DavidF[1] is currently offline  DavidF[1]
Messages: 94
Registered: April 2012
Member
ecat...@gmail.com writes:

> Does the aspect keyword just keep the aspect ratio of the contour plot the same?

The ASPECT keyword should be used to set the aspect ratio of the plot to whatever aspect it is you want. If you want 5 units in Y and 10 units in X, then the aspect ratio of 5./10. If you have 10 units of Y and 5 units of X, then the aspect ratio you want is 10./5. You will have to decide the aspect ratio based on the X and Y ranges of your plot. In your original post, you had these the same, so I suggested an aspect ratio of 1.0.

Cheers,

David
Re: Contour Plot Issues [message #80841 is a reply to message #80840] Thu, 12 July 2012 14:59 Go to previous message
Oana Coman is currently offline  Oana Coman
Messages: 27
Registered: December 2011
Junior Member
Hi David,
Thanks for the response!
Does the aspect keyword just keep the aspect ratio of the contour plot the same? I've been running it with multiple contour plots and it looks like the plot width/height is remaining constant while the distances between my tick marks have to adjust to that constant plot and so the distances between my x-ticks and y-ticks are not matching up so my contour does not look right proportionally :(
I'm looking for something where my plot width/height will adjust to keep a constant spacing between tick marks. Like, if there is 1 inch between x=0 and x=10, so then there should also be 1 inch between y=0 and y=10. Depending on what I'm plotting, sometimes my y-axis will go from -10 to 10 and my x-axis will go from -20 to 20, so I want to plot size to be smaller in the y-direction...it should only cover 2 inches whereas my x-axis should cover 4 if we use the example above. Or if my y-axis goes from -15 to 25 and my x from 0 to 10, my y-axis should cover 4 inches and x should cover 1.
Maybe I am doing it incorrectly? Updated code below:
cgContour,z,x,y, /Fill,$
levels=levels, C_colors=Indgen(numLevels(1))+1,$
c_labels=levels, /Outline,$
xminor=5, yminor=5,$
xtickinterval=10, ytickinterval=10,$
xticks=20,yticks=20,$
xstyle=1, ystyle=1,$
Aspect=1.0, /Window
Or would this depend more on the Window than the contour?

Thanks for all the help!


On Thursday, July 12, 2012 1:44:35 PM UTC-7, David Fanning wrote:
> ecatcom1@gmail.com writes:
>
> > Hi All! I have a seemingly-simple issue that I can't for the life of me get to work, and another issue mainly of existence.
> >
> > The first: I am trying to get a contour plot to plot with the spacing between minor/major ticks to be the same in the x and y direction. No matter what I try, I can't get this to work. I need to size of the plot itself to be able to change (so if i have 10 major ticks in x and 20 in y, I don't want the plot to be that size when, say, the next plot has 5 ticks in x and 15 in y because then the spacing between the x and y ticks won't be the same). Hope that made sense!
> >
> > Here's my code:
> >
> > cgContour,z,x,y, /Fill,$ ;Position=[0.125,0.025,0.9,0.8] I had a colorbar, but I can't hardcode a size to this plot since it will mess with my tick interval lengths depending on number of ticks I have, so commented this out
> > levels=levels, C_colors=Indgen(numLevels(1))+1,$
> > c_labels=levels, /Outline,$
> > xminor=5, yminor=5,$ ;tried hardcoding the number of minor ticks
> > xtickinterval=10, ytickinterval=10,$ ;tried hardcoding the interval size
> > xticks=20,yticks=20,$ ;even tried hardcoding the number of ticks
> > xstyle=1, ystyle=1,$
> > xrange=[-20,20],yrange=[-20,20], /Window ;and tried to give it the same range as a last desperate plea to see if it would give me the same distance between ticks....but nope.
> > Help!
>
> Here it took me two minutes to add an ASPECT keyword to cgContour plot
> for you. Set the ASPECT=1.0 and you will have what you want:
>
> cgContour, ..., Aspect=1.0, /Window
>
> Find the new program here:
>
> http://www.idlcoyote.com/programs/cgcontour.pro
>
> > The second issue: Is there a contour plot option anywhere that will >
> > allow me to dynamically change the x and y range so i can zoom in/out?
>
> Alas, not on a filled contour. It would be MUCH easier if you
> gridded your data yourself and worked with the gridded data
> as an image. Then almost anything is possible. :-)
>
> 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.")
Re: Contour Plot Issues [message #80842 is a reply to message #80841] Thu, 12 July 2012 13:44 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
ecatcom1@gmail.com writes:

> Hi All! I have a seemingly-simple issue that I can't for the life of me get to work, and another issue mainly of existence.
>
> The first: I am trying to get a contour plot to plot with the spacing between minor/major ticks to be the same in the x and y direction. No matter what I try, I can't get this to work. I need to size of the plot itself to be able to change (so if i have 10 major ticks in x and 20 in y, I don't want the plot to be that size when, say, the next plot has 5 ticks in x and 15 in y because then the spacing between the x and y ticks won't be the same). Hope that made sense!
>
> Here's my code:
>
> cgContour,z,x,y, /Fill,$ ;Position=[0.125,0.025,0.9,0.8] I had a colorbar, but I can't hardcode a size to this plot since it will mess with my tick interval lengths depending on number of ticks I have, so commented this out
> levels=levels, C_colors=Indgen(numLevels(1))+1,$
> c_labels=levels, /Outline,$
> xminor=5, yminor=5,$ ;tried hardcoding the number of minor ticks
> xtickinterval=10, ytickinterval=10,$ ;tried hardcoding the interval size
> xticks=20,yticks=20,$ ;even tried hardcoding the number of ticks
> xstyle=1, ystyle=1,$
> xrange=[-20,20],yrange=[-20,20], /Window ;and tried to give it the same range as a last desperate plea to see if it would give me the same distance between ticks....but nope.
> Help!

Here it took me two minutes to add an ASPECT keyword to cgContour plot
for you. Set the ASPECT=1.0 and you will have what you want:

cgContour, ..., Aspect=1.0, /Window

Find the new program here:

http://www.idlcoyote.com/programs/cgcontour.pro

> The second issue: Is there a contour plot option anywhere that will >
> allow me to dynamically change the x and y range so i can zoom in/out?

Alas, not on a filled contour. It would be MUCH easier if you
gridded your data yourself and worked with the gridded data
as an image. Then almost anything is possible. :-)

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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Fastest way to list combinations
Next Topic: Re: Array Integration

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:39:42 PDT 2025

Total time taken to generate the page: 0.00844 seconds