Home > demo2 > format_ticks.m

format_ticks

PURPOSE ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS ^

function [hx,hy] =format_ticks(h,tickx,ticky,tickposx,tickposy,rotx,roty,offset,varargin)

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BEGIN HEADER
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Name: format_tick.m

Usage: [hx,hy] = ...
          format_tick(h,tickx,ticky,tickposx,tickposy,rotx,roty,offset,...
                      varargin);

Description: Replace or appends XTickLabels and YTickLabels of axis handle
             h with input tickx and ticky array

***NOTE!***: BE SURE TO DELETE ANY PREVIOUS TEXT OBJECTS CREATED BY THIS
             FUNCTION BEFORE RUNNING THIS ON THE SAME FIGURE TWICE

Required Inputs:
       h        : handle of axis to change tick labels (can use gca)
       tickx    : cell array of tick labels or string to append to current
                  labels
                  (Defaults to appending degree symbols if not input)

Optional Inputs
       ticky    : cell array of tick labels or string to append to current
                  labels (Can use [] or not specify to ignore) 
       tickposx : Vector of x positions where you want the tick labels
                  (Can use [] or not specify to ignore)
       tickposy : Vector of y positions where you want the tick labels
                  (Can use [] or not specify to ignore) 
       rotx     : Number of degrees to rotate x tick labels 
                  (Can use [] or not specify to ignore) Default = 0.0
       roty     : Number of degrees to rotate y tick labels
                  (Can use [] or not specify to ignore) Default = 0.0
       offset   : Label offsets from axis in fraction of total range
                  (Can use [] or not specify to ignore) Default = 0.0

Optional Inputs:%                
                Any standard text formatting parameters such as 
                'FontSize','FontWeight',etc.
                Use the same way you would in a set command after putting
                in the required input values.

Outputs:
        hx: handle of text objects created for XTickLabels
        hy: handle of text objects created for YTickLabels

Function Calls:
               None

Required Data Files:
                    None


Example:
       ;Example 1: Append Degree Symbols to X-Axis of a Plot
       figure;
       plot(1:10,1:10);
       [hx,hy] = format_ticks(gca);

       ;Example 2: Append Degree Symbolts to X and Y Axes of a Plot
       figure;
       plot(1:10,1:10);
       [hx,hy] = format_ticks(gca,'^{\circ}','^{\circ}');

       ;Example 2: Append Degree Symbolts to X and Y Axes of a Plot and
       ;           put a 45 degree tilt on them
       figure;
       plot(1:10,1:10);
       [hx,hy] = format_ticks(gca,'^{\circ}','^{\circ}',[],[],45,45);
       
       ;Example 3: Make a plot with fractions on the x tick labels
       figure
       plot(1:10,1:10);
       [hx,hy] = format_ticks(gca,{'$1$','$2\frac{1}{2}$','$9\frac{1}{2}$'},...
                 [],[1,2.5,9.5]);

       ;Example 4: Make a plot with degrees on y tick label and fractions
       ;           on x
       figure 
       plot(0:10,0:10);
       [hx,hy] = format_ticks(gca,...
                 {'$0$','$2\frac{1}{2}$','$5$','$7\frac{1}{2}$','$10$'},...
                 '$^{\circ}$',[0,2.5,5,7.5,10],[],0,45,[],...
                 'FontSize',16,'FontWeight','Bold');

Change Log:
           08/19/2007: Origin Version Created by Alex Hayes
                       (hayes@gps.caltech.edu)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BEGIN FUNCTION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %% BEGIN HEADER
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0006 %Name: format_tick.m
0007 %
0008 %Usage: [hx,hy] = ...
0009 %          format_tick(h,tickx,ticky,tickposx,tickposy,rotx,roty,offset,...
0010 %                      varargin);
0011 %
0012 %Description: Replace or appends XTickLabels and YTickLabels of axis handle
0013 %             h with input tickx and ticky array
0014 %
0015 %***NOTE!***: BE SURE TO DELETE ANY PREVIOUS TEXT OBJECTS CREATED BY THIS
0016 %             FUNCTION BEFORE RUNNING THIS ON THE SAME FIGURE TWICE
0017 %
0018 %Required Inputs:
0019 %       h        : handle of axis to change tick labels (can use gca)
0020 %       tickx    : cell array of tick labels or string to append to current
0021 %                  labels
0022 %                  (Defaults to appending degree symbols if not input)
0023 %
0024 %Optional Inputs
0025 %       ticky    : cell array of tick labels or string to append to current
0026 %                  labels (Can use [] or not specify to ignore)
0027 %       tickposx : Vector of x positions where you want the tick labels
0028 %                  (Can use [] or not specify to ignore)
0029 %       tickposy : Vector of y positions where you want the tick labels
0030 %                  (Can use [] or not specify to ignore)
0031 %       rotx     : Number of degrees to rotate x tick labels
0032 %                  (Can use [] or not specify to ignore) Default = 0.0
0033 %       roty     : Number of degrees to rotate y tick labels
0034 %                  (Can use [] or not specify to ignore) Default = 0.0
0035 %       offset   : Label offsets from axis in fraction of total range
0036 %                  (Can use [] or not specify to ignore) Default = 0.0
0037 %
0038 %Optional Inputs:%
0039 %                Any standard text formatting parameters such as
0040 %                'FontSize','FontWeight',etc.
0041 %                Use the same way you would in a set command after putting
0042 %                in the required input values.
0043 %
0044 %Outputs:
0045 %        hx: handle of text objects created for XTickLabels
0046 %        hy: handle of text objects created for YTickLabels
0047 %
0048 %Function Calls:
0049 %               None
0050 %
0051 %Required Data Files:
0052 %                    None
0053 %
0054 %
0055 %Example:
0056 %       ;Example 1: Append Degree Symbols to X-Axis of a Plot
0057 %       figure;
0058 %       plot(1:10,1:10);
0059 %       [hx,hy] = format_ticks(gca);
0060 %
0061 %       ;Example 2: Append Degree Symbolts to X and Y Axes of a Plot
0062 %       figure;
0063 %       plot(1:10,1:10);
0064 %       [hx,hy] = format_ticks(gca,'^{\circ}','^{\circ}');
0065 %
0066 %       ;Example 2: Append Degree Symbolts to X and Y Axes of a Plot and
0067 %       ;           put a 45 degree tilt on them
0068 %       figure;
0069 %       plot(1:10,1:10);
0070 %       [hx,hy] = format_ticks(gca,'^{\circ}','^{\circ}',[],[],45,45);
0071 %
0072 %       ;Example 3: Make a plot with fractions on the x tick labels
0073 %       figure
0074 %       plot(1:10,1:10);
0075 %       [hx,hy] = format_ticks(gca,{'$1$','$2\frac{1}{2}$','$9\frac{1}{2}$'},...
0076 %                 [],[1,2.5,9.5]);
0077 %
0078 %       ;Example 4: Make a plot with degrees on y tick label and fractions
0079 %       ;           on x
0080 %       figure
0081 %       plot(0:10,0:10);
0082 %       [hx,hy] = format_ticks(gca,...
0083 %                 {'$0$','$2\frac{1}{2}$','$5$','$7\frac{1}{2}$','$10$'},...
0084 %                 '$^{\circ}$',[0,2.5,5,7.5,10],[],0,45,[],...
0085 %                 'FontSize',16,'FontWeight','Bold');
0086 %
0087 %Change Log:
0088 %           08/19/2007: Origin Version Created by Alex Hayes
0089 %                       (hayes@gps.caltech.edu)
0090 %
0091 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0092 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0093 %% BEGIN FUNCTION
0094 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0095 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0096 function [hx,hy] = ...
0097     format_ticks(h,tickx,ticky,tickposx,tickposy,rotx,roty,offset,varargin)
0098 
0099 %define axis text offset (percentage of total range)
0100 if ~exist('offset','var');
0101     offset = 0.02;
0102 elseif length(offset) == 0;
0103     offset = 0.02;
0104 end;
0105 
0106 %make sure the axis handle input really exists
0107 if ~exist('h','var');
0108     h = gca;
0109     warning(['Axis handle NOT Input, Defaulting to Current Axes, '...
0110         num2str(h)]);
0111 elseif length(h) == 0;
0112     h = gca;
0113     warning(['Axis Handle NOT Input, Defaulting to Current Axes, '...
0114         num2str(h)]);
0115 elseif ~ishandle(h(1))
0116     warning(['Input (' num2str(h(1)) ') is NOT an axis handle, ' ...
0117         'defaulting to current axis, ' num2str(h)]);
0118         h = gca;
0119 end;
0120 
0121 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0122 %%BEGIN: FIRST THE X-AXIS TICK LABELS
0123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0124 %fix the XTickLabels if they have been erased in the past
0125 if length(get(h,'XTickLabel'))==0; 
0126     set(h,'XTickLabel',get(h,'XTick'));
0127 end;
0128 %set the xtick positions if entered
0129 if exist('tickposx','var');
0130     if length(tickposx) > 0;
0131         set(h,'XTick',tickposx);
0132     end;
0133     tickposx = get(h,'XTick');
0134      set(h,'XTickLabel',tickposx);
0135 end;
0136 %make sure the xtick positions are in the xlimit range
0137 if exist('tickposx','var');
0138     if length(tickposx) > 0;
0139         lim = get(h,'XLim');
0140         if lim(1) > min(tickposx);
0141             lim(1) = min(tickposx);
0142         end;
0143         if lim(2) < max(tickposx);
0144             lim(2) = max(tickposx);
0145         end;
0146         set(h,'XLim',lim);
0147     end;
0148 end;
0149 %get the tick labels and positions if the user did not input them
0150 if ~exist('tickx','var');
0151     tickx = get(h,'XTickLabel');
0152     if ischar(tickx);
0153         temp = tickx;
0154         tickx = cell(1,size(temp,1));
0155         for j=1:size(temp,1);
0156             tickx{j} = strtrim( temp(j,:) );
0157         end;
0158     end;
0159     append = '^{\circ}';
0160     for j=1:length(tickx);
0161         tickx{j} = [tickx{j} append];
0162     end;
0163 elseif length(tickx) == 0;
0164     tickx = get(h,'XTickLabel');
0165     if ischar(tickx);
0166         temp = tickx;
0167         tickx = cell(1,size(temp,1));
0168         for j=1:size(temp,1);
0169             tickx{j} = strtrim( temp(j,:) );
0170         end;
0171     end;
0172     append = '^{\circ}';
0173     for j=1:length(tickx);
0174         tickx{j} = [tickx{j} append];
0175     end;
0176 elseif isstr(tickx);
0177     append = tickx;
0178     tickx = get(h,'XTickLabel');
0179     if ischar(tickx);
0180         temp = tickx;
0181         tickx = cell(1,size(temp,1));
0182         for j=1:size(temp,1);
0183             tickx{j} = strtrim( temp(j,:) );
0184         end;
0185     end;
0186     if strcmp(append(1),'$');
0187         for j=1:length(tickx);
0188             tickx{j} = ['$' tickx{j} append(2:end)];
0189         end;
0190     else;            
0191         for j=1:length(tickx);
0192             tickx{j} = [tickx{j} append];
0193         end;
0194     end;
0195 elseif ~iscell(tickx );
0196     warning(['Input TICKX variable is not a compatible string ' ...
0197         'or cell array! Returning...']);
0198     return;
0199 end;
0200 %find out if we have to use the LaTex interpreter
0201 temp = tickx{1};
0202 if strcmp(temp(1),'$');
0203     latex_on = 1;
0204 else;
0205     latex_on = 0;
0206 end;
0207 %erase the current tick label
0208 set(h,'XTickLabel',{});
0209 %get the x tick positions if the user did not input them
0210 if ~exist('tickposx','var');
0211     tickposx = get(h,'XTick');
0212 elseif length(tickx) == 0;
0213     tickposx = get(h,'XTick');
0214 end;
0215 %get the y tick positions if the user did not input them
0216 if ~exist('tickposy','var');
0217     tickposy = get(h,'YTick');
0218 elseif length(tickposy) == 0;
0219     tickposy = get(h,'YTick');
0220 end;
0221 %set the new tick positions
0222 set(h,'YTick',tickposy);
0223 set(h,'XTick',tickposx);
0224 %check the lengths of the xtick positions and xtick labels
0225 l1 = length(tickx);
0226 l2 = length(tickposx);
0227 if l1==0; 
0228     set(h,'XTickLabel',tickx);
0229 end;
0230 if l1~=l2;
0231     disp(['Length of XTick = ' num2str(length(tickposx))]);
0232     disp(['Length of XTickLabel = ' num2str(length(tickx))]);
0233     if l2 < l1;
0234         warning(['Reducing Length of XTickLabel!']);
0235     else;
0236         warning(['Reducing Length of XTick!']);
0237     end;   
0238     l3 = min([l1,l2]);
0239 
0240     
0241     tickx = tickx{1:l3};
0242     tickposx = tickposx(1:l3);
0243 end;
0244 %set rotation to 0 if not input
0245 if ~exist('rotx','var');
0246     rotx = 0;
0247 elseif length(rotx) == 0; 
0248     rotx = 0;
0249 end;
0250 %Convert the cell labels to a character string
0251 %tickx = char(tickx);
0252 tickx = cellstr(tickx);
0253 %Make the XTICKS!
0254 lim = get(h,'YLim');
0255 if min(tickposy) < lim(1);
0256     lim(1) = min(tickposy);
0257 end;
0258 if max(tickposy) > lim(2);
0259     lim(2) = max(tickposy);
0260 end;
0261 if rotx == 0;
0262     if latex_on;
0263         hx = text(tickposx,...
0264             repmat(lim(1)-offset*(lim(2)-lim(1)),length(tickposx),1),...
0265             tickx,'HorizontalAlignment','center',...
0266             'VerticalAlignment','top','rotation',rotx,'interpreter','LaTex');
0267     else;
0268         hx = text(tickposx,...
0269             repmat(lim(1)-offset*(lim(2)-lim(1)),length(tickposx),1),...
0270             tickx,'HorizontalAlignment','center',...
0271             'VerticalAlignment','top','rotation',rotx);
0272     end;
0273 elseif rotx < 0;
0274     if latex_on;
0275         hx = text(tickposx,...
0276             repmat(lim(1)-offset*(lim(2)-lim(1)),length(tickposx),1),...
0277             tickx,'HorizontalAlignment','left','interpreter','LaTex',...
0278             'VerticalAlignment','middlefi','rotation',rotx);
0279     else;
0280         hx = text(tickposx,...
0281             repmat(lim(1)-offset*(lim(2)-lim(1)),length(tickposx),1),...
0282             tickx,'HorizontalAlignment','left',...
0283              'VerticalAlignment','middle','rotation',rotx);
0284     end;
0285 else;
0286     if latex_on;
0287         hx = text(tickposx,...
0288             repmat(lim(1)-offset*(lim(2)-lim(1)),length(tickposx),1),...
0289             tickx,'HorizontalAlignment','right','interpreter','LaTex',...
0290             'VerticalAlignment','middle','rotation',rotx);
0291     else;
0292         hx = text(tickposx,...
0293             repmat(lim(1)-offset*(lim(2)-lim(2)),length(tickposx),1),...
0294             tickx,'HorizontalAlignment','right',...
0295             'VerticalAlignment','middle','rotation',rotx);
0296     end;
0297 end;
0298 %Get and set the text size and weight
0299 set(hx,'FontSize',get(h,'FontSize'));
0300 set(hx,'FontWeight',get(h,'FontWeight'));
0301 
0302 %Set the additional parameters if they were input
0303 if length(varargin) > 2;
0304     command_string = ['set(hx'];
0305     for j=1:2:length(varargin);
0306         command_string = [command_string ',' ...
0307             '''' varargin{j} ''',varargin{' num2str(j+1) '}'];
0308     end;
0309     command_string = [command_string ');'];
0310     eval(command_string);
0311 end;
0312 
0313 
0314 % Fix the xlabel
0315 hxlabel=get(h,'xlabel');
0316 if ~isempty(get(hxlabel,'string'))
0317   set(hx,'unit','points');
0318   tkext=median(cell2mat(get(hx,'Extent')));
0319   set(hx,'unit','data');
0320   set(hxlabel,'unit','points');
0321   xlpos=get(hxlabel,'Position');
0322   set(hxlabel, 'Position',[xlpos(1), xlpos(2)-tkext(4)]);
0323 end
0324 
0325 
0326 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0327 %%END: FIRST THE X-AXIS TICK LABELS
0328 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0329 
0330 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0331 %%BEGIN: NOW THE Y-AXIS TICK LABELS
0332 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0333 %only move forward if we are doing anything to the yticks
0334 if ~exist('ticky');
0335     hy = -1;
0336 elseif length(ticky)==0;
0337     hy = -1;
0338 else;
0339     %fix the YTickLabels if they have been erased in the past
0340     if length(get(h,'YTickLabel'))==0;
0341         set(h,'YTickLabel',get(h,'YTick'));
0342     end;
0343     %set the ytick positions if entered
0344     if exist('tickposy','var');
0345         if length(tickposy) > 0;
0346             set(h,'YTick',tickposy);
0347             set(h,'YTickLabel',tickposy);
0348         end;
0349     end;
0350     %make sure the xtick positions are in the xlimit range
0351     if exist('tickposy','var');
0352         if length(tickposy) > 0;
0353             lim = get(h,'YLim');
0354             if lim(1) > min(tickposy);
0355                 lim(1) = min(tickposy);
0356             end;
0357             if lim(2) < max(tickposy);
0358                 lim(2) = max(tickposy);
0359             end;
0360             set(h,'YLim',lim);
0361         end;
0362     end;
0363     %get the tick labels and positions if the user did not input them
0364     if ~exist('ticky','var');
0365         ticky = get(h,'YTickLabel');
0366         if ischar(ticky);
0367             temp = ticky;
0368             ticky = cell(1,size(temp,1));
0369             for j=1:size(temp,1);
0370                 ticky{j} = strtrim( temp(j,:) );
0371             end;
0372         end;
0373         append = '^{\circ}';
0374         for j=1:length(ticky);
0375             ticky{j} = [ticky{j} append];
0376         end;
0377     elseif length(ticky) == 0;
0378         ticky = get(h,'YTickLabel');
0379         if ischar(ticky);
0380             temp = ticky;
0381             ticky = cell(1,size(temp,1));
0382             for j=1:size(temp,1);
0383                 ticky{j} = strtrim( temp(j,:) );
0384             end;
0385         end;
0386         append = '^{\circ}';
0387         for j=1:length(ticky);
0388             ticky{j} = [ticky{j} append];
0389         end;
0390     elseif isstr(ticky);
0391         append = ticky;
0392         ticky = get(h,'YTickLabel');
0393         if ischar(ticky);
0394             temp = ticky;
0395             ticky = cell(1,size(temp,1));
0396             for j=1:size(temp,1);
0397                 ticky{j} = strtrim( temp(j,:) );
0398             end;
0399         end;
0400         if strcmp(append(1),'$');
0401             for j=1:length(ticky);
0402                 ticky{j} = ['$' ticky{j} append(2:end)];
0403             end;
0404         else;
0405             for j=1:length(ticky);
0406                 ticky{j} = [ticky{j} append];
0407             end;
0408         end;
0409     elseif ~iscell(ticky );
0410         warning(['Input TICKY variable is not a compatible string ' ...
0411             'or cell array! Returning...']);
0412         return;
0413     end;
0414     %find out if we have to use the LaTex interpreter
0415     temp = ticky{1};
0416     if strcmp(temp(1),'$');
0417         latex_on = 1;
0418     else;
0419         latex_on = 0;
0420     end;
0421     %erase the current tick label
0422     set(h,'YTickLabel',{});
0423     %get the x tick positions if the user did not input them
0424     if ~exist('tickposy','var');
0425         tickposy = get(h,'YTick');
0426     elseif length(ticky) == 0;
0427         tickposy = get(h,'YTick');
0428     end;
0429     %get the x tick positions if the user did not input them
0430     if ~exist('tickposx','var');
0431         tickposx = get(h,'YTick');
0432     elseif length(tickposx) == 0;
0433         tickposx = get(h,'XTick');
0434     end;
0435     %set the new tick positions
0436     set(h,'YTick',tickposy);
0437 %    set(h,'XTick',tickposx);
0438     %check the lengths of the xtick positions and xtick labels
0439     l1 = length(ticky);
0440     l2 = length(tickposy);
0441     if l1==0;
0442         set(h,'YTickLabel',ticky);
0443     end;
0444     if l1~=l2;
0445         disp(['Length of YTick = ' num2str(length(tickposy))]);
0446         disp(['Length of YTickLabel = ' num2str(length(ticky))]);
0447         if l2 < l1;
0448             warning(['Reducing Length of YTickLabel!']);
0449         else;
0450             warning(['Reducing Length of YTick!']);
0451         end;
0452         l3 = min([l1,l2]);
0453         ticky = ticky{1:l3};
0454         tickposy = tickposy(1:l3);
0455     end;
0456     %set rotation to 0 if not input
0457     if ~exist('roty','var');
0458         roty = 0;
0459     elseif length(roty) == 0;
0460         roty = 0;
0461     end;
0462     %Convert the cell labels to a character string
0463     %ticky = char(ticky);
0464     ticky = cellstr(ticky);
0465     %Make the YTICKS!
0466     lim = get(h,'XLim');
0467     if min(tickposx) < lim(1);
0468         lim(1) = min(tickposx);
0469     end;
0470     if max(tickposx) > lim(2);
0471         lim(2) = max(tickposx);
0472     end;
0473     if roty == 0;
0474         if latex_on;
0475             hy = text(...
0476                 repmat(lim(1)-offset*(lim(2)-lim(1)),length(tickposy),1),...
0477                 tickposy,...
0478                 ticky,'VerticalAlignment','middle',...
0479                 'HorizontalAlignment','right','rotation',roty,'interpreter','LaTex');
0480         else;
0481             hy = text(...
0482                 repmat(lim(1)-offset*(lim(2)-lim(1)),length(tickposy),1),...
0483                 tickposy,...
0484                 ticky,'VerticalAlignment','middle',...
0485                 'HorizontalAlignment','right','rotation',roty);
0486         end;
0487     elseif roty < 180;
0488          if latex_on;
0489             hy = text(...
0490                 repmat(lim(1)-offset*(lim(2)-lim(1)),length(tickposy),1),...
0491                 tickposy,...
0492                 ticky,'VerticalAlignment','middle',...
0493                 'HorizontalAlignment','right','rotation',roty,'interpreter','LaTex');
0494         else;
0495             hy = text(...
0496                 repmat(lim(1)-offset*(lim(2)-lim(1)),length(tickposy),1),...
0497                 tickposy,...
0498                 ticky,'VerticalAlignment','middle',...
0499                 'HorizontalAlignment','right','rotation',roty);
0500         end;
0501     else;
0502           if latex_on;
0503             hy = text(...
0504                 repmat(lim(1)-offset*(lim(2)-lim(1)),length(tickposy),1),...
0505                 tickposy,...
0506                 ticky,'VerticalAlignment','middle',...
0507                 'HorizontalAlignment','right','rotation',roty,'interpreter','LaTex');
0508         else;
0509             hy = text(...
0510                 repmat(lim(1)-offset*(lim(2)-lim(1)),length(tickposy),1),...
0511                 tickposy,...
0512                 ticky,'VerticalAlignment','middle',...
0513                 'HorizontalAlignment','right','rotation',roty);
0514         end;
0515     end;
0516     %Get and set the text size and weight
0517     set(hy,'FontSize',get(h,'FontSize'));
0518     set(hy,'FontWeight',get(h,'FontWeight'));
0519 
0520     %Set the additional parameters if they were input
0521     if length(varargin) > 2;
0522         command_string = ['set(hy'];
0523         for j=1:2:length(varargin);
0524             command_string = [command_string ',' ...
0525                 '''' varargin{j} ''',varargin{' num2str(j+1) '}'];
0526         end;
0527         command_string = [command_string ');'];
0528         eval(command_string);
0529     end;
0530 end;
0531         
0532     
0533 
0534 
0535 
0536 
0537 
0538 
0539 
0540 
0541 
0542 
0543 
0544 
0545 
0546 
0547 
0548 
0549 
0550 
0551 
0552 
0553 
0554 
0555 
0556 
0557 
0558 
0559 
0560 
0561 
0562 
0563 
0564 
0565 
0566 
0567 
0568 
0569 
0570 
0571 
0572 
0573 
0574 
0575 
0576

Generated on Sat 22-Aug-2009 22:15:36 by m2html © 2003