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

Home » Public Forums » archive » Re: Teaching an Elephant to Dance
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Teaching an Elephant to Dance [message #77589 is a reply to message #77588] Mon, 12 September 2011 09:48 Go to previous messageGo to previous message
Mark Piper is currently offline  Mark Piper
Messages: 198
Registered: December 2009
Senior Member
On 9/11/2011 12:14 PM, David Fanning wrote:
> Folks,
>
> Because what I assumed was impossible has turned out to be
> possible, and because I don't want others to struggle
> for three days in frustration, Coyote and I have
> decided to share the secret of how to produce a simple
> contour plot using the IDL 8.1 function graphics
> commands. (The alternative, of course, would be to try to
> get rich by writing the only IDL 8.1 graphics documentation
> worth a damn, but the audience seems small to us.)
>
> You can find the article here:
>
> http://www.idlcoyote.com/ng_tips/elephant.php
>
> Cheers,
>
> David
>
>

There's an easier way to make this plot, but you have to work with the
fact that COLORBAR wants 256 values and is tied to the data.

I've used code similar to what I posted earlier
[ https://groups.google.com/d/msg/comp.lang.idl-pvwave/QHJmvrK ybz/WMR2aD5g0P8J],
and I put in a few comments to show where my code differs from yours.

I've tested this on my laptop (64-bit Win XP + 32-bit Linux (Ubuntu
10.10)) and the Tech Support Mac running Lion.

mp


pro ng_discrete_colorbar1
compile_opt idl2

data = randomu(-3L, 9, 9)
levels = [0.0, 0.25, 0.5, 0.75, 1.0] ; note top level

; COLORBAR wants 256 colors, so replicate the 4 desired colors.
colors = [[!color.red], [!color.blue], [!color.green], [!color.yellow]]
n_colors = n_elements(colors)
step_ct = congrid(colors, 3, 256)

w = window(dimensions=[750, 400])
w.refresh, /disable

c = contour(data, $
/current, $
c_value=levels, $
/fill, $
position=[0.1, 0.1, 0.9, 0.8], $
rgb_table=step_ct, $
rgb_indices=bytscl(indgen(n_colors))) ; this is a bug in 8.1

over = contour(data, $
/current, $
c_value=levels, $
axis_style=0, $
font_size=10, $
/c_label_show, $
/c_use_label_orientation, $
c_label_interval=0.6, $ ; thin the number of labels
position=[0.1, 0.1, 0.9, 0.8])

cb = colorbar(target=c, $
tickname=string(levels, format='(f4.2)'), $ ; use the levels
position=[0.1, 0.90, 0.9, 0.95])

w.refresh
end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: More Function Graphics Confusion
Next Topic: Re: Trouble exporting vector .eps file from ivolume

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

Current Time: Thu Oct 09 23:56:09 PDT 2025

Total time taken to generate the page: 0.63736 seconds