Home > atmlab > geoplots > gmt > extra_legend.m

extra_legend

PURPOSE ^

EXTRA_LEGEND create an extra legend box for the missing values

SYNOPSIS ^

function file = extra_legend(in)

DESCRIPTION ^

 EXTRA_LEGEND create an extra legend box for the missing values

 Purpose: To create an extra legend box for the missing values

 IN     struct:
                   in.xtra_legend.type = 'nan','fg',or 'bg'
                   in.xtra_legend.name = e.g. 'NaN
                
 OUT    %s         fileThe output-file location

 Created by Salomon Eliasson
 $Id: extra_legend.m 8362 2013-04-20 18:30:35Z seliasson $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

extra_legend.m

SOURCE CODE ^

0001 function file = extra_legend(in)
0002 % EXTRA_LEGEND create an extra legend box for the missing values
0003 %
0004 % Purpose: To create an extra legend box for the missing values
0005 %
0006 % IN     struct:
0007 %                   in.xtra_legend.type = 'nan','fg',or 'bg'
0008 %                   in.xtra_legend.name = e.g. 'NaN
0009 %
0010 % OUT    %s         fileThe output-file location
0011 %
0012 % Created by Salomon Eliasson
0013 % $Id: extra_legend.m 8362 2013-04-20 18:30:35Z seliasson $
0014 if ~isstruct(in.extra_legend)
0015     % then you have provided the psscale comamnd directly
0016     file = '';
0017     return
0018 end
0019 X = in.extra_legend;
0020 assert(all(isfield(X,{'name','type'})),['atmlab:' mfilename],'Must have fields ''name'' and ''type''')
0021 %create nan.cpt for NaN colorbox
0022 switch X.type
0023     case 'nan'
0024      file = 'color_nan.cpt'; %save to local file
0025      tmp = splitstring(in.color_nan,'/');
0026     case 'fg'
0027       file = 'color_fg.cpt'; %save to local file
0028         tmp = splitstring(in.color_foreground,'/');  
0029     case 'bg'
0030       file = 'color_bg.cpt'; %save to local file
0031       tmp = splitstring(in.color_background,'/');  
0032     otherwise
0033         error(['atmlab' mfilename ':badInput'],'choose type nan,fg, or bg')
0034 end
0035 str = sprintf('%s\t%s\t%s',tmp{1},tmp{2},tmp{3});
0036 
0037 fid = fopen(file,'w');
0038 fprintf(fid,'%s\n',['#cpt file created by: ' mfilename]);
0039 fprintf(fid,'%s\n','# Created for extra colorbox');
0040 fprintf(fid,'%s\n%s\n','#COLOR_MODEL = RGB','#');
0041 fprintf(fid,'%i\t%s\t%i\t%s\t%s\n',1,str,2,str,[';' X.name]);
0042 fclose(fid);

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