0001 function p = PlotTicks(xy,varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 if nargin < 1,
0036 error('Incorrect number of parameters (type ''help <a href="matlab:help PlotTicks">PlotTicks</a>'' for details).');
0037 end
0038
0039
0040 direction = 'v';
0041 yx = 0;
0042 color = [];
0043 s = [];
0044 v = {};
0045
0046
0047 both = false;
0048 if ~isempty(varargin) && isnumeric(varargin{1}),
0049 x = xy;
0050 y = varargin{1};
0051 varargin = {varargin{2:end}};
0052 both = true;
0053 end
0054
0055
0056 n = 1;
0057 for i = 1:2:length(varargin),
0058 if ~ischar(varargin{i}),
0059 error(['Parameter ' num2str(i+2) ' is not a property (type ''help <a href="matlab:help PlotTicks">PlotTicks</a>'' for details).']);
0060 end
0061 switch(lower(varargin{i})),
0062 case 'size',
0063 s = varargin{i+1};
0064 if ~isdscalar(s) && ~isdvector(s),
0065 error('Incorrect value for property ''size'' (type ''help <a href="matlab:help PlotTicks">PlotTicks</a>'' for details).');
0066 end
0067
0068 case 'direction',
0069 direction = lower(varargin{i+1});
0070 if ~isastring(direction,'h','v'),
0071 error('Incorrect value for property ''direction'' (type ''help <a href="matlab:help PlotTicks">PlotTicks</a>'' for details).');
0072 end
0073
0074 case 'color',
0075 color = varargin{i+1};
0076 if ~isdmatrix(color,'>=0','<=1') || size(color,2) ~= 3,
0077 error('Incorrect value for property ''color'' (type ''help <a href="matlab:help PlotTicks">PlotTicks</a>'' for details).');
0078 end
0079
0080 otherwise,
0081 v = {varargin{i:end}};
0082 if ~isa(v,'cell'), v = {v}; end
0083 break;
0084 end
0085 end
0086
0087 if ~both,
0088 if strcmp(direction,'v'),
0089 x = xy;
0090 y = yx;
0091 else
0092 x = yx;
0093 y = xy;
0094 end
0095 end
0096
0097
0098 if ~isdvector(x) | ~isdvector(y) | (~isdscalar(x) & ~isdscalar(y) & any(size(x) ~= size(y))),
0099 error('Incorrect abscissae/ordinates (type ''help <a href="matlab:help PlotTicks">PlotTicks</a>'' for details).');
0100 else
0101 if isscalar(x),
0102 x = x*ones(size(y));
0103 else
0104 x = x(:);
0105 end
0106 if isscalar(y),
0107 y = y*ones(size(x));
0108 else
0109 y = y(:);
0110 end
0111 end
0112
0113
0114 if isempty(s),
0115 if strcmp(direction,'v'),
0116 s = min(diff(unique(y)))*0.75;
0117 else
0118 s = min(diff(unique(x)))*0.75;
0119 end
0120 if isempty(s), s = 0.75; end
0121 end
0122
0123 s = s(:);
0124 if length(s) == 1,
0125 s = repmat(s,length(x),1);
0126 elseif any(size(x) ~= size(s)),
0127 error('Inconsistent numbers of abscissae/ordinates and sizes (type ''help <a href="matlab:help PlotTicks">PlotTicks</a>'' for details).');
0128 end
0129
0130 hold on;
0131 if strcmp(direction,'v'),
0132 if isempty(color),
0133 for i = 1:length(x),
0134 plot([x(i) x(i)],[y(i)-s(i)/2 y(i)+s(i)/2],v{:});
0135 end
0136 else
0137 if size(color,1) == 1, color = repmat(color,length(x),1); end
0138 for i = 1:length(x),
0139 plot([x(i) x(i)],[y(i)-s(i)/2 y(i)+s(i)/2],'color',color(i,:),v{:});
0140 end
0141 end
0142 else
0143 if isempty(color),
0144 for i = 1:length(x),
0145 plot([x(i)-s(i)/2 x(i)+s(i)/2],[y(i) y(i)],v{:});
0146 end
0147 else
0148 if size(color,1) == 1, color = repmat(color,length(x),1); end
0149 for i = 1:length(x),
0150 plot([x(i)-s(i)/2 x(i)+s(i)/2],[y(i) y(i)],'color',color(i,:),v{:});
0151 end
0152 end
0153 end