wolffd@0: function hText = rotate_xlabel(degrees, newlabels) wolffd@0: wolffd@0: % Posted to comp.soft-sys.matlab on 2003-05-01 13:45:36 PST wolffd@0: % by David Borger (borger@ix.netcom.com) wolffd@0: wolffd@0: xtl = get(gca,'XTickLabel'); wolffd@0: set(gca,'XTickLabel',''); wolffd@0: lxtl = length(xtl); wolffd@0: xtl = newlabels; wolffd@0: if 0 % nargin>1 wolffd@0: lnl = length(newlabels); wolffd@0: if lnl~=lxtl wolffd@0: error('Number of new labels must equal number of old'); wolffd@0: end; wolffd@0: xtl = newlabels; wolffd@0: end; wolffd@0: wolffd@0: wolffd@0: hxLabel=get(gca,'XLabel'); wolffd@0: xLP=get(hxLabel,'Position'); wolffd@0: y=xLP(2); wolffd@0: XTick=get(gca,'XTick'); wolffd@0: y=repmat(y,length(XTick),1); wolffd@0: %fs=get(gca,'fontsize'); wolffd@0: fs = 12; wolffd@0: hText=text(XTick,y,xtl,'fontsize',fs); wolffd@0: set(hText,'Rotation',degrees,'HorizontalAlignment','right'); wolffd@0: wolffd@0: % Modifications by KPM wolffd@0: wolffd@0: ylim = get(gca,'ylim'); wolffd@0: height = ylim(2)-ylim(1); wolffd@0: N = length(hText); wolffd@0: for i=1:N wolffd@0: voffset = ylim(2) - 0*height; wolffd@0: set(hText(i), 'position', [i voffset 0]); wolffd@0: end