function [h_x, h_y] = draw_axes(draw_x, draw_y)
% draw_axes: draw the x and/or y axes.
% function [h_x, h_y] = draw_axes(draw_x, draw_y)
% if draw_x ~= 0 then draw the x axis.
% if draw_y ~= 0 then draw the y axis.
% returns the axes handles
  
% $Id:$
% Copyright J. V. Mansbridge, CSIRO, Wed Aug 19 14:46:42 EST 1998

if nargin == 0
  draw_x = 1;
  draw_y = 1;
elseif nargin == 1
  draw_y = 1;
elseif nargin > 2
  error('There should be only 2 input arguments')
end

hold_state_gca = get(gca, 'NextPlot');
hold_state_gcf = get(gcf, 'NextPlot');
set(gca, 'NextPlot', 'add');
set(gcf, 'NextPlot', 'add');
ax = axis;

if draw_x
  if (ax(3) < 0) & (ax(4) > 0)
    hh_x = plot([ax(1) ax(2)], [0 0], 'linewidth', 2);
  end
end

if draw_y
  if (ax(1) < 0) & (ax(2) > 0)
    hh_y = plot([0 0], [ax(3) ax(4)], 'linewidth', 2);
  end
end

axis(ax)
set(gca, 'NextPlot', hold_state_gca);
set(gcf, 'NextPlot', hold_state_gcf);

if nargout == 1
  h_x = hh_x;
elseif nargout == 2
  h_x = hh_x;
  h_y = hh_y;
end

  