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

Home » Public Forums » archive » cgcontour colours for 2 panel plot
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
cgcontour colours for 2 panel plot [message #84810] Tue, 11 June 2013 20:53 Go to next message
ej is currently offline  ej
Messages: 4
Registered: June 2013
Junior Member
Hi

I want to plot a 2 panel figure of a density field with cgcontour. I would like to display just one colour bar. Is there a good way to make sure that the colours in each panel correspond to the same density? At the moment I use "clip" to adjust the colour range used by the second contour plot so that the colours in each panel correspond to the same density but I was hoping there is a better way.

Thanks!
Re: cgcontour colours for 2 panel plot [message #84822 is a reply to message #84810] Wed, 12 June 2013 06:04 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
ej writes:

> I want to plot a 2 panel figure of a density field with cgcontour. I would like to display just one colour bar. Is there a good way to make sure that the colours in each panel correspond to the same density? At the moment I use "clip" to adjust the colour range used by the second contour plot so that the colours in each panel correspond to the same density but I was hoping there is a better way.

Yeah, I can understand why you might be looking for a better way, since
I can't imagine how your method can possibly work. :-)

To get two contour plots to use the same colors for their fill values,
you simple use the same LEVELS and C_COLOR values for both. Simple as
that, really. You probably also have to take care to set the minimum
level to the minimum of the two data sets.

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: cgcontour colours for 2 panel plot [message #84828 is a reply to message #84822] Wed, 12 June 2013 08:43 Go to previous messageGo to next message
ej is currently offline  ej
Messages: 4
Registered: June 2013
Junior Member
Hi David,

Thanks for the quick reply. Maybe i've misunderstood what clip was doing! I have two density fields each with different min and max.
If the first field has (rho1_min,rho1_max) and uses a colour table range [0,255] then for the second field i was finding the colour range that corresponded to
(rho2_min,rho2_max) where e.g. if rho1_min =0, then the colour table range for the second field is [255*rho2_min/rho1_max, 255*rho2_max/rho1_max],
Assuming that rho1_min < rho2_min <rho2_min <rho1_max.
Does this make sense?

Are there any examples of c_colors that i can look at to get started?
Re: cgcontour colours for 2 panel plot [message #84829 is a reply to message #84828] Wed, 12 June 2013 08:53 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
elise.jennings@gmail.com writes:

> Thanks for the quick reply. Maybe i've misunderstood what clip was doing! I have two density fields each with different min and max.
> If the first field has (rho1_min,rho1_max) and uses a colour table range [0,255] then for the second field i was finding the colour range that corresponded to
> (rho2_min,rho2_max) where e.g. if rho1_min =0, then the colour table range for the second field is [255*rho2_min/rho1_max, 255*rho2_max/rho1_max],
> Assuming that rho1_min < rho2_min <rho2_min <rho1_max.
> Does this make sense?

No, but maybe its just a proofreading problem. :-)

> Are there any examples of c_colors that i can look at to get started?

There is the small contour multiples plot in the Coyote Plot Gallery:

http://www.idlcoyote.com/gallery/index.html#SMALLMULTIPLES

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: cgcontour colours for 2 panel plot [message #84830 is a reply to message #84829] Wed, 12 June 2013 09:18 Go to previous messageGo to next message
ej is currently offline  ej
Messages: 4
Registered: June 2013
Junior Member
Great, thanks.
There was a typo in my last post which probably didn't help.
rho1_min < rho2_min < rho2_max < rho1_max
This clipping method did produce the right colours in each panel for one colour bar but it was annoying.

Thanks again!
Re: cgcontour colours for 2 panel plot [message #84831 is a reply to message #84828] Wed, 12 June 2013 09:25 Go to previous messageGo to next message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
If I may, let me throw a different way of handling this in here, that doesn't bother with color tables.

Let's say you have 5 levels you want. Here's some pseudo-code below. You shouldn't have to worry about where in the color table one range falls relative to the other in this case.

I've also put a snippet of some IDL notes I have up that may or may not help here:
https://docs.google.com/file/d/0BxRn65i6z-Z5bjhFUUM1RWNVb0k/ edit?usp=sharing

;define some colors
colors = ['blue', 'red', 'green', 'yellow', 'orange']

nLev = N_ELEMENTS(colors)

;and get the palette for these colors:
rgb = cgCOLOR(colors, /TRIPLE)

;define some levels:
levs = FINDGEN(nLev)*10

;and make the plots:
cgContour, data1, LEVELS = levs, PALETTE=rgb
cgContour, data2, LEVELS = levs, PALETTE=rgb

;now define the tickmarks for the colorbar:
l_ticks = [STRING(levs, FORMAT='(F4.1)'), ' ']

;now make the color bar
cgCOLORBAR, NCOLORS=nLev, PALETTE=rgb, DIVISION=nLev, TICKNAMES=l_ticks
Re: cgcontour colours for 2 panel plot [message #84832 is a reply to message #84830] Wed, 12 June 2013 09:26 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
elise.jennings@gmail.com writes:

> This clipping method did produce the right colours in each panel for one colour bar but it was annoying.

I would imagine. It would be like estimating your shoe size from a
picture of Michael Jordan's sneakers. :-)

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: cgcontour colours for 2 panel plot [message #84833 is a reply to message #84831] Wed, 12 June 2013 09:35 Go to previous messageGo to next message
ej is currently offline  ej
Messages: 4
Registered: June 2013
Junior Member
Great, thanks Phillip!
Re: cgcontour colours for 2 panel plot [message #84837 is a reply to message #84831] Wed, 12 June 2013 14:10 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Phillip Bitzer writes:

> I've also put a snippet of some IDL notes I have up that may or may not help here:
> https://docs.google.com/file/d/0BxRn65i6z-Z5bjhFUUM1RWNVb0k/ edit?usp=sharing

I made the mistake of letting Coyote read this, and he found this line
on your last page:

Note: unfortunately cgSurface is one of the few Coyote routines
that uses a color table, not a palette. So, getting the colors
to match our contour plot is not as straightforward as it was
before. There are ways to do it, but we’ll save that for another day.

After reading it he was howling and whining and frothing at the mouth,
so I finally gave him 10 minutes off so he could go fix the damn thing.
Here it is. He has finally settled down and gotten back to work. :-(

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

You can call it like this:

cgloadct, rgb_table=pal, 33
cgsurface, cgdemodata(2), Shaded=1, palette=pal, /elevation

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: cgcontour colours for 2 panel plot [message #84838 is a reply to message #84837] Wed, 12 June 2013 14:32 Go to previous message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
My apologies to Coyote, but also, my thanks go to him. One of things I really like about his graphics system is that I don't have to touch color tables. :-)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Polyfill overlap issue
Next Topic: dialog_pickfile - multiple directories

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

Current Time: Wed Oct 08 15:05:49 PDT 2025

Total time taken to generate the page: 0.00619 seconds