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

Home » Public Forums » archive » Re: How to plot multiple cgContour plots using the same colour levels (but containing differing data)
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: How to plot multiple cgContour plots using the same colour levels (but containing differing data) [message #76379] Tue, 31 May 2011 14:16 Go to next message
Balt is currently offline  Balt
Messages: 16
Registered: May 2010
Junior Member
Hi David,

That's exactly what I was looking for, thanks! Brilliant idea also to
include a demo data set to explain concepts and ideas in your library.

Cheers

- Balt
Re: How to plot multiple cgContour plots using the same colour levels (but containing differing data) [message #76398 is a reply to message #76379] Mon, 30 May 2011 21:03 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Balt writes:

> Well, since by clipping to less than the max value I'm always going to
> be below the max color palette entry, out of bounds should not be a
> condition that ever occurs?

Sorry, I guess I miss understood what you were trying
to do. Is this the kind of thing you are trying to do?

data = cgDemoData(2)
data1 = Scale_Vector(data, 400, 1500)
data2 = Scale_Vector(data, 0, 900)
data3 = Scale_Vector(data, 250, 1350)

levels = Indgen(16)*100
cgLoadCT, 33, NColors=16, Bottom=1
c_colors = Indgen(16) + 1
cgDisplay, 900, 300
!P.Multi=[0,3,1]
ymargin = !Y.OMargin
!Y.OMargin=[3,10]
cgContour, data1, Levels=levels, C_Color=c_colors, /Fill, $
XStyle=1, YStyle=1
cgContour, data2, Levels=levels, C_Color=c_colors, /Fill, $
XStyle=1, YStyle=1
cgContour, data3, Levels=levels, C_Color=c_colors, /Fill, $
XStyle=1, YStyle=1
cgColorbar, NColors=16, Bottom=1, RANGE=[Min(data), Max(data)], $
Divisions=16, position = [0.25, 0.85, 0.75, 0.89]
!P.Multi=0
!Y.OMargin = ymargin
END

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: How to plot multiple cgContour plots using the same colour levels (but containing differing data) [message #76399 is a reply to message #76398] Mon, 30 May 2011 20:25 Go to previous messageGo to next message
manodeep@gmail.com is currently offline  manodeep@gmail.com
Messages: 33
Registered: June 2006
Member
On May 30, 9:20 pm, Balt <bindermue...@gmail.com> wrote:
> Well, since by clipping to less than the max value I'm always going to
> be below the max color palette entry, out of bounds should not be a
> condition that ever occurs?
>
> Chees
>
> - Balt

The way I have done it in the past is by getting the global (min,max)
of all the data sets. The global min corresponds to color 0 and the
global max to color 255. Now you have to scale the individual data
sets:

Ncolors = 255
data_color_range = (data_max-data_min)/(global_max-
global_min)*Ncolors
data_color_max = (data_max/global_max*Ncolors) < Ncolors
data_color_min = (data_color_max - data_color_range) > 0
data = byte(scale_vector(data,data_color_min,data_color_max))

...rinse, repeat for each data set.

The colorbar can then plotted as usual ranging from global_min to
global_max in data space and 0-Ncolors in color space.

Cheers,
Manodeep
Re: How to plot multiple cgContour plots using the same colour levels (but containing differing data) [message #76400 is a reply to message #76399] Mon, 30 May 2011 19:20 Go to previous messageGo to next message
Balt is currently offline  Balt
Messages: 16
Registered: May 2010
Junior Member
Well, since by clipping to less than the max value I'm always going to
be below the max color palette entry, out of bounds should not be a
condition that ever occurs?

Chees

- Balt
Re: How to plot multiple cgContour plots using the same colour levels (but containing differing data) [message #76401 is a reply to message #76400] Mon, 30 May 2011 17:31 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Balt writes:

> I think I may have found the solution: Clip the colour palette like
> this:
>
> cgLoadCT, 20, RGB_Table=pal, CLIP=[0, max(data)/max_temp*255]
>
> - max_temp contains the maximum temperature in any of the data sets.
> - data is a vector containing the temperatures for the current plot.
>
> Does that make sense or is this a "it works by chance"?

It is a "work by chance" solution. I have color bars with
"out of bounds" colors added to them. Maybe I'll just add
them to cgColorbar. :-)

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: How to plot multiple cgContour plots using the same colour levels (but containing differing data) [message #76402 is a reply to message #76401] Mon, 30 May 2011 16:54 Go to previous messageGo to next message
Balt is currently offline  Balt
Messages: 16
Registered: May 2010
Junior Member
I think I may have found the solution: Clip the colour palette like
this:

cgLoadCT, 20, RGB_Table=pal, CLIP=[0, max(data)/max_temp*255]

- max_temp contains the maximum temperature in any of the data sets.
- data is a vector containing the temperatures for the current plot.

Does that make sense or is this a "it works by chance"?

Cheers

- Balt

On May 31, 9:30 am, Balt <bindermue...@gmail.com> wrote:
> Hi all,
>
> I have 3 x 3 cgContour plots on one page. I would like the colour
> scale in each of the plots to be the same to facilitate inter-plot
> comparison of the data (and to only require one color bar also). I
> know the min/max values for all datasets, so I was hoping there's a
> simple way to tell cgContour that for plot X, expand the colour scale
> to include the supplied min/max values. That however appears not
> possible. Am I missing something?
>
> Cheers
>
> - Balt
Re: How to plot multiple cgContour plots using the same colour levels (but containing differing data) [message #88304 is a reply to message #76398] Thu, 10 April 2014 13:42 Go to previous messageGo to next message
siumtesfai is currently offline  siumtesfai
Messages: 62
Registered: April 2013
Member
On Tuesday, May 31, 2011 12:03:53 AM UTC-4, David Fanning wrote:
> Balt writes:
>
>> Well, since by clipping to less than the max value I'm always going to
>> be below the max color palette entry, out of bounds should not be a
>> condition that ever occurs?
>
> Sorry, I guess I miss understood what you were trying
> to do. Is this the kind of thing you are trying to do?
>
> data = cgDemoData(2)
> data1 = Scale_Vector(data, 400, 1500)
> data2 = Scale_Vector(data, 0, 900)
> data3 = Scale_Vector(data, 250, 1350)
>
> levels = Indgen(16)*100
> cgLoadCT, 33, NColors=16, Bottom=1
> c_colors = Indgen(16) + 1
> cgDisplay, 900, 300
> !P.Multi=[0,3,1]
> ymargin = !Y.OMargin
> !Y.OMargin=[3,10]
> cgContour, data1, Levels=levels, C_Color=c_colors, /Fill, $
> XStyle=1, YStyle=1
> cgContour, data2, Levels=levels, C_Color=c_colors, /Fill, $
> XStyle=1, YStyle=1
> cgContour, data3, Levels=levels, C_Color=c_colors, /Fill, $
> XStyle=1, YStyle=1
> cgColorbar, NColors=16, Bottom=1, RANGE=[Min(data), Max(data)], $
> Divisions=16, position = [0.25, 0.85, 0.75, 0.89]
> !P.Multi=0
> !Y.OMargin = ymargin
> END
>
> 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.")

Hell David,

The above code for contour plot will not work when you have data that ranges between negative and positive . It works the above code when all your data have positive value.

What would you be your advice or suggestion on that.

Best regards
Re: How to plot multiple cgContour plots using the same colour levels (but containing differing data) [message #88305 is a reply to message #88304] Thu, 10 April 2014 13:51 Go to previous messageGo to next message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
On Thursday, April 10, 2014 3:42:26 PM UTC-5, IDL Beginner wrote:
>
>
> Hell David,
>
>
>
> The above code for contour plot will not work when you have data that ranges between negative and positive . It works the above code when all your data have positive value.
>
>

Well, I'm not David, but you need to set the levels appropriately. This line:

levels = Indgen(16)*100

produces levels of 0, 100, ..., 1500. You should change that to something more appropriate for your data.

And, if you change the number of levels (here, 16) you'll need to change a few things in the rest of the code too.
Re: How to plot multiple cgContour plots using the same colour levels (but containing differing data) [message #88306 is a reply to message #88304] Thu, 10 April 2014 14:02 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
IDL Beginner writes:

> The above code for contour plot will not work when you have data that ranges between negative and positive . It works the above code when all your data have positive value.
>
> What would you be your advice or suggestion on that.

My best advice would be to not use other people's code unless you
understand it. Rather, I would spend 15-20 minutes with your data and
the cgContour documentation, reading about the various keywords and what
they are used for. Start with the very simplest contour plot:

cgContour, data

Then, read and add keywords to see what they do. Once you have an
understanding of how things work, it will be simple for you to
understand why these commands aren't "working" with negative data.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: How to plot multiple cgContour plots using the same colour levels (but containing differing data) [message #88309 is a reply to message #88306] Fri, 11 April 2014 11:44 Go to previous message
siumtesfai is currently offline  siumtesfai
Messages: 62
Registered: April 2013
Member
On Thursday, April 10, 2014 5:02:43 PM UTC-4, David Fanning wrote:
> IDL Beginner writes:
>
>
>
>> The above code for contour plot will not work when you have data that ranges between negative and positive . It works the above code when all your data have positive value.
>
>>
>
>> What would you be your advice or suggestion on that.
>
>
>
> My best advice would be to not use other people's code unless you
>
> understand it. Rather, I would spend 15-20 minutes with your data and
>
> the cgContour documentation, reading about the various keywords and what
>
> they are used for. Start with the very simplest contour plot:
>
>
>
> cgContour, data
>
>
>
> Then, read and add keywords to see what they do. Once you have an
>
> understanding of how things work, it will be simple for you to
>
> understand why these commands aren't "working" with negative data.
>
>
>
> Cheers,
>
>
>
> David
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

Ok, I did my homework and it has to do with the combination of levles and step.

Thanks
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: call ITK from IDL
Next Topic: Error with cg output and ImageMagick

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

Current Time: Wed Oct 08 13:44:35 PDT 2025

Total time taken to generate the page: 0.00645 seconds