annotate toolboxes/FullBNT-1.0.7/KPMtools/rotate_xlabel.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function hText = rotate_xlabel(degrees, newlabels)
wolffd@0 2
wolffd@0 3 % Posted to comp.soft-sys.matlab on 2003-05-01 13:45:36 PST
wolffd@0 4 % by David Borger (borger@ix.netcom.com)
wolffd@0 5
wolffd@0 6 xtl = get(gca,'XTickLabel');
wolffd@0 7 set(gca,'XTickLabel','');
wolffd@0 8 lxtl = length(xtl);
wolffd@0 9 xtl = newlabels;
wolffd@0 10 if 0 % nargin>1
wolffd@0 11 lnl = length(newlabels);
wolffd@0 12 if lnl~=lxtl
wolffd@0 13 error('Number of new labels must equal number of old');
wolffd@0 14 end;
wolffd@0 15 xtl = newlabels;
wolffd@0 16 end;
wolffd@0 17
wolffd@0 18
wolffd@0 19 hxLabel=get(gca,'XLabel');
wolffd@0 20 xLP=get(hxLabel,'Position');
wolffd@0 21 y=xLP(2);
wolffd@0 22 XTick=get(gca,'XTick');
wolffd@0 23 y=repmat(y,length(XTick),1);
wolffd@0 24 %fs=get(gca,'fontsize');
wolffd@0 25 fs = 12;
wolffd@0 26 hText=text(XTick,y,xtl,'fontsize',fs);
wolffd@0 27 set(hText,'Rotation',degrees,'HorizontalAlignment','right');
wolffd@0 28
wolffd@0 29 % Modifications by KPM
wolffd@0 30
wolffd@0 31 ylim = get(gca,'ylim');
wolffd@0 32 height = ylim(2)-ylim(1);
wolffd@0 33 N = length(hText);
wolffd@0 34 for i=1:N
wolffd@0 35 voffset = ylim(2) - 0*height;
wolffd@0 36 set(hText(i), 'position', [i voffset 0]);
wolffd@0 37 end