The kind of legend you are looking for is called a "colorbar". This kind of legend is a built-in part of IDL Object Graphics (it's called 'IDLgrColorbar'). It is also a built-in object available at the click of a button in any iTools (iPlot, iSurface, etc.) menu. However, there is no such built-in code for the same in IDL Direct Graphics.
If you go onto Google and search for keywords "IDL" + "colorbar", you will probably find several third-party free source code downloads that will give you a widely configurable colorbar object for IDL Direct Graphics. They are probably based on either PLOTS or POLYFILL and have some kind of implementation similar to the following:
; Draws a vertical color ramp of the current color table with lower-left
; corner positioned at pixel coordinate [xOff, yOff] and
; pixel width of width
; Syntax: EX_DIRECT_GRAPHICS_COLORBAR, 16, 20, 10
PRO ex_direct_graphics_colorbar, barWidth, xOff, yOff
device, DECOMPOSED=0 ; Enable indexed color
loadct, 5 ; Load a colorful color table
window, /FREE
for i = 0, 255 do begin
plots, [xOff, xOff + barWidth], [yOff + i, yOff + i], COLOR=i, /DEVICE
endfor
END
James Jones
|