Folks,
Am I the only one who finds function graphics confusing? :-(
Here is some code that produces a filled contour plot correctly.
;*********************************************************** **
PRO contour_experiments
data = RandomU(-3L, 9, 9)
LoadCT, 0
TVLCT, 255, 0, 0, 0 ; Red
TVLCT, 0, 0, 255, 1 ; Blue
TVLCT, 0, 255, 0, 2 ; Green
TVLCT, 255, 255, 0, 3 ; Yellow
TVLCT, rgb, /GET
rgb = Congrid(rgb[0:3, *], 256, 3)
w = Window(DIMENSIONS=[750, 400])
w.Refresh, /DISABLE
levels = [0.00, 0.25, 0.50, 0.75, 1.00]
over = Contour(data, /CURRENT, C_VALUE=levels, AXIS_STYLE=0, $
C_COLOR='black', FONT_SIZE=10, C_LABEL_SHOW=Replicate(1,4), $
C_USE_LABEL_ORIENTATION=1, POSITION=[0.1, 0.1, 0.9, 0.8], $
C_LABEL_INTERVAL=0.6)
c = Contour(data, /CURRENT, C_VALUE=levels, /FILL, $
POSITION=[0.1, 0.1, 0.9, 0.8], AXIS_STYLE=2, $
RGB_TABLE=rgb, RGB_INDICES=BytScl(Indgen(4)))
over.Order, /BRING_FORWARD
c.GetData, z, x, y
z[0] = 0.0 & z[1] = 1.0
fakeContourPlot = Contour(z, /CURRENT, C_VALUE=levels, /FILL, $
POSITION=[0.1, 0.1, 0.9, 0.8], AXIS_STYLE=2, $
RGB_TABLE=rgb, RGB_INDICES=Indgen(256))
; fakeContourPlot = Image(cgdemodata(7), RGB_TABLE=rgb, /current)
cb = Colorbar(TARGET=fakeContourPlot , $
POSITION=[0.1, 0.90, 0.9, 0.95], MAJOR=5)
fakeContourPlot.Delete
w.Refresh
END
;*********************************************************** **
On lines 23-25 you find code for a fake contour plot. This is
required (on my machine) to produce a color bar with correctly
labeled tick marks.
If you comment these three lines out, and uncomment line 26, which
uses a fake image plot, rather than a fake contour plot, for this
purpose, the color bar just doesn't show up at all!
Can anyone think of a reason for this?
It appears the fakeContourPlot.Delete line is the culprit.
When I use the contour plot, this line deletes only the contour
plot, but the color bar stays. When I use the image plot, this line
deletes BOTH the image and the color bar. Is this another feature
I should be aware of?
I realize this is a bit of a contrived example, but I
am working on an article and this inconsistency is
driving me crazy!
I am beginning to understand why there is no documentation
for function graphics. People think you have switched over
to writing fiction. And, bad fiction at that. No one will
believe it actually works this way. :-(
On another note:
I have updated my Teaching an Elephant to Dance article
this morning to reflect Mark Piper's better way of doing
things, although Mark didn't get back to me to answer any
of my questions. I think he is probably still researching
them (knowing how slowly this goes!), but Coyote, ever the
paranoid, thinks something more sinister has happened and
he has been silenced. We are both waiting anxiously for a
word from him.
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.")
|