Documentation of mcont2


Global Index (short | long) | Local contents | Local Index (short | long)


Function Synopsis

[h, c] = mcont2(data, cint, mstyle, usezero);

Help text


  [h, c] = mcont2(data, cint, mstyle, zeroline);

  data = map data
  cint:  if scalar, then it's the contour interval
         if vector, then it's a vector of contours levels
  mstyle:  map projection (default 'giso')
  zeroline:  'zeroline', 'z', or 1 will produce a zero line
             'nozeroline', 'n', or 0 will produce no zero line
             Default is 'nozeroline'

  This function uses the mapping toolbox to contour the
  input 'data' matrix.  It assumes that the x and y axes
  are defined in the global variables XAX and YAX, 
  respectively.

  Note that this function works best for cylindrical, or
  pseudocylindrical projections.  (Try typing 'maps' to 
  see the style of the projection you want to use).  It
  may work for others too, but I haven't tested it.

  The default mstyle is Global Isometric ('giso'), 
  centered at the center of the variable FRAME.  This should
  all be pretty easy to change, though.


Cross-Reference Information

This function calls This function is called by

Listing of function mcont2

function [h, c] = mcont2(data, cint, mstyle, usezero);

%  Dan Vimont, 2 September, 1999

if nargin < 4; usezero = 0; end;
if isstr(usezero);
  if strcmp(lower(usezero(1)), 'z'); usezero = 1;
  elseif strcmp(lower(usezero(1)), 'n'); usezero = 0;
  else
    error('usezero must be either ''zeroline'', or ''nozeroline'' ');
  end
else
  if ~ismember([0 1], usezero);
    error('zeroline must be 0 (nozeroline) or 1 (zeroline)')
  end
end

data = squeeze(data);

%  First, determine if hold is 'on', or 'off'.

next_ax = lower(get(gca, 'NextPlot'));
if strcmp(next_ax, 'replace');  cla;  end;

%  Get the global varaibles XAX YAX and FRAME

global XAX YAX FRAME
if (size(XAX, 1) == 1); XAX = XAX'; end;
if (size(YAX, 1) == 1); YAX = YAX'; end;

[m, n] = size(data);
if or((m~=length(YAX)), (n~=length(XAX)));
  error('[length(YAX) length(XAX)] must equal size(data)');
end

%  Set defaults

if nargin < 2; cint = (max(max(data))-min(min(data)))/10; end;
if nargin < 3; mstyle = 'giso'; end;
origin = [];
lab = 0;
line_style = 'k';

%  Redefine XAX, YAX and data for global contouring -- allowing 
%  for wrapping around the globe.

if (FRAME(2) - FRAME(1) == 360);
  data2 = [data data(:,1)];
  XAX2 = [XAX; XAX(1)+360];
else
  data2 = data;
  XAX2 = XAX;
end;

%  Define contour interval;

if isscalar(cint);
  clev = sort([-cint:-cint:min(min(data2)) ...
                cint:cint:max(max(data2))]);
else
  clev = cint;
end

if usezero; clev = sort([clev 0]); end

%  Define map axis:
if ~ismap(gca);
  axesm('mapprojection', mstyle, ...
        'origin', origin, ...
        'maplatlimit', FRAME(3:4), ...
        'maplonlimit', FRAME(1:2));
end

%  Plot the data

[h, c] = pncontm(XAX2, YAX, data2, clev, lab, line_style);
% axis_limits

set(gca, 'NextPlot', next_ax);