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