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

Home » Public Forums » archive » Re: Explain Contour Plot to Me
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: Explain Contour Plot to Me [message #77608 is a reply to message #77510] Fri, 09 September 2011 16:50 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

>> I had to expand the 4 colors into a full 256 color table with 257
>> contour levels to make the color bar display correctly.
>
> Well, that sort of boggles the mind, but OK, maybe
> that's how you do it. Unfortunately, it begs the
> question of how you are now going to overlay the
> contour lines themselves on this filled contour
> plot. This, of course, is what I really wanted,
> although my previous example was reduced to the
> basics just to get the colors right.

OK, we are making a little progress here. But there
are still a couple of problems. The color bar insists
on querying the data to get its range. The range apparently
cannot be set, so the labels on the color bar are wrong
and don't correspond to the contour levels. Can anyone
think of a way to fix these? (I could, of course, force
the contour labels to be what I want them to be, but
aside from this feeling like cheating, I can't do it
because the TICKNAME keyword will crash my machine.)

Also, I cannot seem to set a character size for the plot
independently of the character size for the contour labels.
Does anyone know how to do this? In this case, I would like
the contour plot to have the same size annotation as the
color bar, with the inside contour labels appearing smaller.

Note that the C_USE_LABEL_ORIENTATION keyword seems to
keep the contour labels right side up, rather than the
jumbled, upside down default values. That's the good
news. The bad news is that is a long keyword to have to
type for every contour plot you want to create!

Here is the code so far.

;-------------------------------------------------------
PRO ContourTest

; Create a simple, random dataset for contouring:
data = RANDOMU(-3L, 9, 9)
LoadCT, 0
TVLCT, 255, 0, 0, 0
TVLCT, 0, 0, 255, 1
TVLCT, 0, 255, 0, 2
TVLCT, 255, 255, 0, 3

levels =[0.25, 0.5, 0.75, 1.00]

; Contour function.
tvlct, rgb, /get
rgb = congrid(rgb[0:3, *], 256, 3)
clevels = findgen(257) / 256.

w = window(dimensions=[500, 400])
ctr = contour(data, /current, c_value=clevels, $
position=[0.1, 0.1, 0.9, 0.8], /fill, $
rgb_table=rgb, rgb_indices=indgen(256), $
axis_style=2, font_size=10)
ctrOver = contour(data, /current, c_value=levels, $
color=cgColor('charcoal', /row, /triple), $
/overplot, c_label_show=Replicate(1, 4), $
c_use_label_orientation=1, font_size=7)
cb = colorbar(target=ctr, $
position=[0.1, 0.90, 0.9, 0.95], $
major=5, border_on=1, font_size=10)

; Can we force the font size to be larger? Apparently, not. :-(
ctr.font_size=10

; Coyote graphics.
levels =[0.0, 0.25, 0.5, 0.75]

cgWindow, WXSize=500, WYSize=400
cgContour, data, LEVELS=levels, C_COLORS=Indgen(4), $
POSITION=[0.1, 0.1, 0.9, 0.8], /FILL, /ADDCMD
cgContour, data, LEVELS=levels, C_COLOR='charcoal', LABEL=1, $
C_CHARSIZE=1.0, /OVERPLOT, /ADDCMD
cgColorBar, NCOLORS=4, RANGE=[0,1], FORMAT='(F0.2)', $
DIVISIONS=4, /FIT, /ADDCMD, MINOR=5, XTICKLEN=1.0
END
;-------------------------------------------------------

And here is a little lagniappe (small gift). A program
to clean up any and all graphics windows on your display.

;-------------------------------------------------------
PRO CleanUp

; Function graphics windows.
w = GetWindows()
FOR j=0,N_Elements(w)-1 DO (w[j]).close

; Widget windows or Coyote Graphics windows.
Widget_Control, /Reset

; IDL direct graphics windows.
WHILE !D.Window GT -1 DO WDelete, !D.Window

END
;-------------------------------------------------------

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Total and Utter Confusion!
Next Topic: Startup City 2011 (September 24th,Mumbai)

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

Current Time: Sat Oct 11 22:27:44 PDT 2025

Total time taken to generate the page: 0.39759 seconds