Re: COLOR BAR [message #2538] |
Wed, 27 July 1994 05:43 |
landers
Messages: 45 Registered: May 1993
|
Member |
|
|
Victor Shvetsky writes:
|>
|> I was wondering if anyone has a routine for widgets that would plot a nice
|> color bar AND put some value on it. I can create a color bar, but I am not
|> able to put text on it NICELY, unless I use XYOUTS.
|> any suggestions would be greatly appreciated.
|>
You can use AXIS, something like this:
; first set up a plot space - make a null plot with no axes
; you could add a Position keyword to put it somewhere special
; Use /NoErase if you're adding the color bar to an existing plot
PLOT,[0,1],/NoData,XStyle=4,YStyle=4
; get the corners of the plot space (in device units)
px = !X.Window * !D.X_VSize
py = !Y.Window * !D.Y_VSize
; get the widths of the plot space
swx = px(1) - px(0)
swy = py(1) - py(0)
; Draw the color bar (colors run from index 0 at left to !D.N_Colors-1
; at right)
TVSCL, FINDGEN(swx) # REPLICATE(1.,swy), px(0),py(0), /Device
; Now add an axis. You can use any of the XRange, XStyle, XTicks, etc.
; keywords to make the axes what you like.
; I usually like to make XTicklen a small negative number so the axis ticks
; hang below the axis, rather than getting lost in the color bar
AXIS, XAxis=0., XRange=[0,10], XTicklen=-0.02
^^^^^^
Your range goes here.....
Luck
;Dave
|
|
|
Re: COLOR BAR [message #2550 is a reply to message #2538] |
Tue, 26 July 1994 10:20  |
mark_cadwell
Messages: 10 Registered: February 1994
|
Junior Member |
|
|
In article <312i3o$o98@news.service.uci.edu>, vshvetsk@fourier.oac.uci.edu
(Victor Shvetsky) wrote:
>
> I was wondering if anyone has a routine for widgets that would plot a nice
> color bar AND put some value on it. I can create a color bar, but I am not able to put text on it NICELY, unless I use XYOUTS.
> any suggestions would be greatly appreciated.
--
I made a routine that created a color coded legend (a color bar) that
went along with a contour plot. I did it by defining a new bar-shaped
drawing window, using the plot function to draw rectangular areas within
the drawing window, and using polyfill to fill in the areas with their
respective colors. Finally, I used xyouts to write text and/or numeric
data into each color area. The text color was defined as either black or
white, depending on which color would contrast best with the color in the
individual rectangular areas.
Drawing the areas and the text fields was a simple matter of setting up
a loop with changing y values (my color bar was vertical).
----------------------------------
mark_cadwell@qmail4.trw.sp.com
|
|
|
Re: COLOR BAR [message #2553 is a reply to message #2550] |
Tue, 26 July 1994 09:43  |
caron
Messages: 16 Registered: May 1994
|
Junior Member |
|
|
Whats wrong with XYOUTS?
heres mine:
PRO draw_colorbar
@control_com
@windraw_com
sh = (wdp.ysize + wdv.ysize) / cc_data_nlevels
for j=0, cc_data_nlevels-1 do begin
color = cc_contour_colors(j)
tv, replicate(color, 40, sh), 0, sh*j
lab = string(format='(E10.3)', cc_contour_levels(j))
labs = strtrim(lab, 2)
lab1 = strmid( labs, 0, 4)
lab2 = strmid( labs, strpos(labs,'E'), 4)
;print, lab, labs, lab1, lab2
xyouts, 1, 20+sh*j, /device, color = 1, charsize = 1.0, lab1
xyouts, 1, 3+sh*j, /device, color = 1, charsize = 1.0, lab2
endfor
END
|
|
|