Viewing contents of file '../idllib/contrib/tappin/graffer/gr_2df_plot.pro'
pro Gr_2df_plot, pdefs, i, csiz, grey_ps=grey_ps
;+
; GR_2DF_PLOT
; Display a 2-d function in GRAFFER
;
; Usage:
; gr_2df_plot, pdefs, i
;
; Argument:
; pdefs struct input The Graffer control structure.
; i int input Which
; csiz float input Charsize scaling (hardcopy only).
;
; Keyword:
; grey_ps input If set & non-zero, then the plot is to
; a PS device without the COLOUR option.
;
; History:
; Original: 10/12/96; SJT
; Made unique in 8.3: 11/2/97; SJT
; Skip if inadequate colours: 8/5/97; SJT
;-
xrange = !X.crange
if (pdefs.xtype) then xrange = 10^xrange
yrange = !Y.crange
if (pdefs.ytype) then yrange = 10^yrange
handle_value, pdefs.data, data, /no_copy
if (data(i).zopts.format eq 1 and $
pdefs.short_colour and $
not keyword_set(grey_ps)) then begin
handle_value, pdefs.data, data, /no_copy, /set
return
endif
handle_value, data(i).xydata, xydata, /no_copy
xmin = xrange(0)
xmax = xrange(1)
ymin = yrange(0)
ymax = yrange(1)
if (xydata.range(0, 0) ne xydata.range(1, 0)) then begin
xmin = xmin > xydata.range(0, 0)
xmax = xmax < xydata.range(1, 0)
endif
if (xydata.range(0, 1) ne xydata.range(1, 1)) then begin
ymin = ymin > xydata.range(0, 1)
ymax = ymax < xydata.range(1, 1)
endif
if (pdefs.xtype) then begin
xmin = alog10(xmin)
xmax = alog10(xmax)
x = 10^(findgen(data(i).ndata) * (xmax-xmin) $
/ float(data(i).ndata-1) + xmin)
endif else x = findgen(data(i).ndata) * (xmax-xmin) $
/ float(data(i).ndata-1) + xmin
if (pdefs.ytype) then begin
ymin = alog10(ymin)
ymax = alog10(ymax)
y = 10^(findgen(data(i).ndata2) * (ymax-ymin) $
/ float(data(i).ndata2-1) + ymin)
endif else y = findgen(1, data(i).ndata2) * (ymax-ymin) $
/ float(data(i).ndata2-1) + ymin
xx = x
yy = y(*)
x = x(*, intarr(data(i).ndata2))
y = y(intarr(data(i).ndata), *)
z = 0. ; Need to define z before we use it.
iexe = execute('z = '+xydata.funct)
s = size(z)
if (s(0) ne 2) then graff_msg, pdefs.ids.message, $
"Function:"+xydata.funct+" does not return a 2-D array" $
else if (data(i).zopts.format eq 0) then begin
if (data(i).zopts.n_levels le 0) then begin
if (data(i).zopts.n_levels eq 0) then nl = 6 $
else nl = -data(i).zopts.n_levels
rg = (max(z, min = mn)-mn)
if (rg eq 0.) then begin
graff_msg, pdefs.ids.message, 'Flat dataset - not able to ' + $
'contour'
goto, restore
endif
levels = rg * (findgen(nl)+.5)/nl + mn
endif else $
levels = data(i).zopts.levels(0:data(i).zopts.n_levels-1)
if (data(i).zopts.label ne 0) then begin
labels = (indgen(abs(data(i).zopts.n_levels)) - $
data(i).zopts.label/2) mod data(i).zopts.label eq 0
endif else labels = 0
contour, z, xx, yy, /overplot, /follow, $
levels = levels, $
c_linestyle = data(i).zopts.style(0:data(i).zopts.n_sty-1 > 0), $
c_colors = data(i).zopts.colours(0:data(i).zopts.n_cols-1 > 0), $
c_thick = data(i).zopts.thick(0:data(i).zopts.n_thick-1 > 0), $
fill = data(i).zopts.fill, c_labels = labels
endif else begin
if (keyword_set(grey_ps)) then colour_range = [0, 255] $
else colour_range = [16, 143 < !D.n_colors-1]
gr_display_img, z, xx, yy, range = data(i).zopts.range, $
colour_range = colour_range, pixel_size = $
data(i).zopts.pxsize
gr_pl_axes, pdefs, csiz, /overlay
endelse
Restore:
handle_value, data(i).xydata, xydata, /no_copy, /set
handle_value, pdefs.data, data, /no_copy, /set
end