Home > atmlab > geoplots > gmt > append_tickannotations.m

append_tickannotations

PURPOSE ^

% APPEND_TICKANNOTATIONS change legend annotations to whatever you want.

SYNOPSIS ^

function file = append_tickannotations(file,annotations)

DESCRIPTION ^

% APPEND_TICKANNOTATIONS change legend annotations to whatever you want.

 Purpose: function that makes it easy to change the legend annotations    to
 whatever you    want.

 IN: 1) file: '%s', the color table file in which to add the annotations.
     2) annotations: cell, '%s' must have the same number of elements as there
     are levels.
 
 OUT: file '%s'

 Created by Salomon Eliasson
 $Id: append_tickannotations.m 7254 2012-01-31 22:40:28Z seliasson $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

append_tickannotations.m

SOURCE CODE ^

0001 function file = append_tickannotations(file,annotations)
0002 %% APPEND_TICKANNOTATIONS change legend annotations to whatever you want.
0003 %
0004 % Purpose: function that makes it easy to change the legend annotations    to
0005 % whatever you    want.
0006 %
0007 % IN: 1) file: '%s', the color table file in which to add the annotations.
0008 %     2) annotations: cell, '%s' must have the same number of elements as there
0009 %     are levels.
0010 %
0011 % OUT: file '%s'
0012 %
0013 % Created by Salomon Eliasson
0014 % $Id: append_tickannotations.m 7254 2012-01-31 22:40:28Z seliasson $
0015 
0016 % READ OLD FILE
0017 fid = fopen(file);
0018 out={};
0019 while 1
0020     s=fgetl(fid);
0021     if (s == -1) break; end
0022     out{end+1}=s;
0023 end
0024 fclose(fid);
0025 
0026 % CHECK INPUT
0027 assert(sum(~cellfun('isempty', regexp(out,'^[-+]?[0-9]*\.?[0-9]+'))) == length(annotations),...
0028     ['gmtlab:' mfilename ':input'],'Number of annotations must match number of ticks')
0029 
0030 fid = fopen(file,'w'); x = 1;
0031 for i = 1:length(out)
0032     if ~isempty(regexp(out{i},'^[-+]?[0-9]*\.?[0-9]+', 'once'))
0033         fprintf(fid,'%s',sprintf('%s ; %s\n',out{i},annotations{x}));
0034         x=x+1;
0035     else
0036         fprintf(fid,'%s\n',out{i});
0037     end
0038 end
0039 fclose(fid);

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005