function[]=quiver_scale(av,x_pos,y_pos,u_scale,scale_text);
% The routine inserts horizontal arrow scale into a quiver plot.
% USAGE:
% av=quiver(lon,lat,u,v,[optional parameters]);
% quiver_scale(av,x_scale_pos,y_scale_pos,u_scale,[scale_text]);
%-----------------------------------------------------
% senya@umd.edu, 04/18/2020
%----------------------------------------------------

if(nargin==0)
disp('USAGE')
disp('1) av=quiver(lon,lat,u,v,[optional parameters]')
disp('2) quiver_scale(av,x_scale_pos,y_scale_pos,u_scale,scale_text)')
return
end

color=get(av,'color');
x = get(av,'XData'); y = get(av,'YData');
u = get(av,'UData'); v = get(av,'VData');
x = [x(:);  x_pos];
y = [y(:);  y_pos];
u = [u(:);  u_scale];
v = [v(:);  0];

xlim =  get(gca,'XLim'); ylim = get(gca,'YLim');

set(av,'Xdata',x, 'Ydata',y, 'Udata',u, 'Vdata',v)

set(gca,'XLim',xlim,'YLim',ylim)

    at=text(x_pos, y_pos,...
          [scale_text],'Color',color);
	  set(at,'HorizontalAlignment','left',...
	  'VerticalAlignment','top');
    
