ticks_format

PURPOSE ^

TICKS_FORMAT - Controls the format of tick labels

SYNOPSIS ^

function ticks_format(x_formatstring, y_formatstring, z_formatstring)

DESCRIPTION ^

TICKS_FORMAT - Controls the format of tick labels

Syntax:  ticks_format(x_formatstring, y_formatstring, z_formatstring);

Inputs:  x_formatstring    %See online help for SPRINTF to learn
         y_formatstring    %more about valid format strings
         z_formatstring

Output:  none

Examples:  ticks_format('%5.2f');
           ticks_format('%5.2f', '%4.1f');
           ticks_format('%4.1f', '%5.2f', '%6.3f');
           ticks_format('%4.1f', '%5.2f', '%+9.2e')

M-files required: none
Subfunctions:  none
MAT-files required: none

See also:  SPRINTF

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function ticks_format(x_formatstring, y_formatstring, z_formatstring)
0002 %TICKS_FORMAT - Controls the format of tick labels
0003 %
0004 %Syntax:  ticks_format(x_formatstring, y_formatstring, z_formatstring);
0005 %
0006 %Inputs:  x_formatstring    %See online help for SPRINTF to learn
0007 %         y_formatstring    %more about valid format strings
0008 %         z_formatstring
0009 %
0010 %Output:  none
0011 %
0012 %Examples:  ticks_format('%5.2f');
0013 %           ticks_format('%5.2f', '%4.1f');
0014 %           ticks_format('%4.1f', '%5.2f', '%6.3f');
0015 %           ticks_format('%4.1f', '%5.2f', '%+9.2e')
0016 %
0017 %M-files required: none
0018 %Subfunctions:  none
0019 %MAT-files required: none
0020 %
0021 %See also:  SPRINTF
0022 
0023 %Author: Denis Gilbert, Ph.D., physical oceanography
0024 %Maurice Lamontagne Institute, Dept. of Fisheries and Oceans Canada
0025 %email: gilbertd@dfo-mpo.gc.ca  Web: http://www.qc.dfo-mpo.gc.ca/iml/
0026 %September 2001; Last revision: 13-Sep-2001
0027 
0028 
0029 if nargin == 1
0030     y_formatstring = x_formatstring;
0031     z_formatstring = x_formatstring;
0032 end
0033 
0034 xtick = get(gca,'xtick');
0035 for i = 1:length(xtick)
0036     xticklabel{i} = sprintf(x_formatstring,xtick(i));
0037 end
0038 set(gca,'xticklabel', xticklabel)
0039 
0040 ytick = get(gca,'ytick');
0041 for i = 1:length(ytick)
0042     yticklabel{i} = sprintf(y_formatstring,ytick(i));
0043 end
0044 set(gca,'yticklabel', yticklabel)
0045 
0046 if nargin == 3
0047     ztick = get(gca,'ztick');
0048     for i = 1:length(ztick)
0049         zticklabel{i} = sprintf(z_formatstring,ztick(i));
0050     end
0051     set(gca,'zticklabel', zticklabel)
0052 end

Generated on Thu 21-Aug-2014 10:40:31 by m2html © 2005