; docformat = 'rst' ;+ ; Simple example of displaying a contour plot in object graphics. ; ; :Params: ; z : in, required, type=2D numeric array ; data to contour ; ; :Keywords: ; n_levels : in, required, type=long ; number of levels for the contour plot ; _extra : in, optional, type=keywords ; keywords to IDLgrContour::init or IDLgrWindow::init ;- pro mg_ogcontour_example, z, n_levels=nlevels, _extra=e compile_opt strictarr _nlevels = n_elements(nlevels) eq 0L ? 20 : nlevels viewgroup = obj_new('IDLgrViewGroup') view = obj_new('IDLgrView') viewgroup->add, view model = obj_new('IDLgrModel') view->add, model fillContour = obj_new('IDLgrContour', z, $ planar=1, geomz=0.0, $ n_levels=_nlevels, $ /fill, c_color=bytscl(bindgen(_nlevels)), $ depth_offset=1, $ _extra=e) model->add, fillContour lineContour = obj_new('IDLgrContour', z, $ planar=1, geomz=0.0, $ n_levels=_nlevels, $ _extra=e) model->add, lineContour fillContour->getProperty, xrange=xr, yrange=yr xc = mg_linear_function(xr, [-0.85, 0.9]) yc = mg_linear_function(yr, [-0.85, 0.9]) fillContour->setProperty, xcoord_conv=xc, ycoord_conv=yc lineContour->setProperty, xcoord_conv=xc, ycoord_conv=yc xaxis = obj_new('IDLgrAxis', direction=0, range=xr) model->add, xaxis yaxis = obj_new('IDLgrAxis', direction=1, range=yr) model->add, yaxis xaxis->setProperty, xcoord_conv=xc, ycoord_conv=yc yaxis->setProperty, xcoord_conv=xc, ycoord_conv=yc palette = obj_new('IDLgrPalette') viewgroup->add, palette palette->loadCT, 5 fillContour->setProperty, palette=palette window = obj_new('IDLgrWindow', dimensions=[500, 500], graphics_tree=viewgroup, _extra=e) window->draw end ; main-level example program convexFilename = filepath('convec.dat', subdir=['examples', 'data']) convec = read_binary(convexFilename, data_type=1, data_dims=[248, 248]) mg_ogcontour_example, convec, n_levels=30 end