David,
Try the following. I realized that I had no NANs in the X-vector, that's
why I never saw the warning message you get. However, that warning
message does not stop you from obtaining the right object, just annoys
you. In the example below, you can generate the data with or without
NANs in the X-vector. You get the plot regardless. And, as long as you
have NANs in Y, you will have 0 in data[0,*].
********************
pro test, x, y, win=win, x_finite=x_finite
; Init the data if not passed.
if n_elements(x) eq 0 then begin
y=findgen(100)+1
y[(indgen(20)+10)*2]=!values.f_nan
if keyword_set(x_finite) then x=findgen(100)+1 else x=y
endif
if size(win, /type) eq 11 then begin
if obj_class(win) ne 'IDLGRWINDOW' then goto, init_win
endif else begin
init_win:
win = obj_new('IDLgrWindow')
endelse
x_min = min(x, max=x_max, /nan) & y_min = min(y, max=y_max, /nan)
x_range = [x_min, x_max] & y_range = [y_min, y_max]
; Normalize plot range.
n_xr = normalize(x_range)
n_yr = normalize(y_range)
Plots_symbol = obj_new('IDLgrSymbol', 2, size=[0.006/n_xr[1],
0.008/n_yr[1]], $
color=[0, 0, 200])
Plots_lines = obj_new('IDLgrPlot', x, y, color=[0, 0, 0],
symbol=Plots_symbol, linestyle=6, $
xcoord_conv=n_xr, ycoord_conv=n_yr, xrange=x_range, yrange=y_range)
x_axis = obj_new('IDLgrAxis', 0, ticklen=0.03, name='X_AXIS',
location=[1000, 0, 0], /exact)
y_axis = obj_new('IDLgrAxis', 1, ticklen=0.03, name='Y_AXIS',
location=[0, 1000, 0], /exact)
X_axis -> setProperty, range=x_range, xcoord_conv=n_xr
Y_axis -> setProperty, range=y_range, ycoord_conv=n_yr
Plots_model = obj_new('IDLgrModel')
Plots_view = obj_new('IDLgrView', viewplane_rect=[-0.1, -0.1, 1.12,
1.16], location=[0.0, 0.0])
Plots_model -> add, Plots_lines
Plots_model -> add, x_axis
Plots_model -> add, y_axis
Plots_view -> add, Plots_model
Container = obj_new('IDL_Container')
Container -> add, Plots_view
Container -> add, Plots_model
Container -> add, Plots_symbol
Plots_lines -> getProperty, data=data
print, 'Min of X from IDLgrPlot equals', min(data[0, *], /nan)
print, 'While in the real data it equals', min(x, /nan)
win -> draw, Plots_view
obj_destroy, Container
end
**********************
Cheers,
Pavel
David Fanning wrote:
> I can't seem to get a vector with a NAN into IDLgrPlot.
> How did you do it?
>
> IDL> a=findgen(11)
> IDL> a[5] = !Values.F_Nan
> IDL> b=findgen(11)
> IDL> ploter = Obj_New("idlgrplot", a, b)
> IDL> ploter = Obj_New("idlgrplot", a, b)
> % Program caused arithmetic error: Floating illegal operand
|