Skip to content

Commit b513e6b

Browse files
new stuff
1 parent f178f69 commit b513e6b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
function axis_setLastXTickLabel(str, varargin)
2+
%axis_setLastXTickLabel(str, <forceAtLim>)
3+
%
4+
% set the last xTickLabel to the given string.
5+
6+
if nargin==2
7+
forceAtLim = varargin{1};
8+
end
9+
10+
h= gca;
11+
xLim= get(h, 'XLim');
12+
xTick= get(h, 'XTick');
13+
xTickLabel= cellstr(get(h, 'XTickLabel'));
14+
if nargin>1 && forceAtLim==2 && xLim(2)==xTick(end),
15+
forceAtLim=1;
16+
end
17+
if nargin>1 && forceAtLim==2,
18+
xTickLabel{end+1}= str;
19+
else
20+
xTickLabel{end}= str;
21+
end
22+
set(h, 'XTickMode','manual', 'XTickLabel',xTickLabel);
23+
24+
%% xTickMode has to be set to 'manual'. Otherwise problems will occur
25+
%% after resizing the figure (a/nd probably when printing it).
26+
27+
if nargin>1 && forceAtLim,
28+
if forceAtLim==2,
29+
xTick(end+1)= xLim(2);
30+
else
31+
xTick(end)= xLim(2);
32+
end
33+
set(h, 'XTick',xTick, 'XLimMode','manual');
34+
end

0 commit comments

Comments
 (0)