cgcontour colours for 2 panel plot [message #84810] |
Tue, 11 June 2013 20:53  |
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 #84829 is a reply to message #84828] |
Wed, 12 June 2013 08:53   |
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 #84831 is a reply to message #84828] |
Wed, 12 June 2013 09:25   |
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 #84837 is a reply to message #84831] |
Wed, 12 June 2013 14:10   |
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.")
|
|
|
|