xtickrot.m

来自「这是图像识别方法bag of feature 的matlab源代码」· M 代码 · 共 75 行

M
75
字号
function h=xtickrot(angle)% XTICKROT  Rotate X tickmarks labels%%%%% current limitsax = axis ;% current axis y directionydir = get(gca,'YDir') ;% set limit modes to manualaxis(axis); % retrieve current labels and ticksxt = get(gca,'XTick') ;xl = get(gca,'XTickLabel') ;% there might be more ticks than labels, or just% one label, repeated for all axesif ischar(xl)	l = xl ;	xl = cell(1,length(xt)) ;	for i = 1:length(xt)		xl{i} = l ;	endelse	xt = xt(1:length(xl)) ;end% add text objectsswitch ydir case 'reverse'	h = text(xt, ax(4)*ones(1,length(xt)), xl) ; case 'normal'	h = text(xt, ax(3)*ones(1,length(xt)), xl) ;end% rotate themif angle > 0 	ha = 'right' ;else	ha = 'left' ;endset(h,'HorizontalAlignment',ha,...			'VerticalAlignment','top', ...			'Rotation',angle);% remove current labelsset(gca,'XTickLabel','')% now deal with the x-labelxll = get(gca,'XLabel') ;if(~isempty(xll))		for i = 1:length(h)		its_units = get(h(i),'Units') ;		set(h(i),'Units', 'normalized') ;		ext(i,:) = get(h(i),'Extent') ;		set(h(i),'Units', its_units) ;	end	set(xll, 'Units','normalized') ;	pos = get(xll,'Position') ;	x0 = pos(1) ;	y0 = min(ext(:,2)) ;	set(xll,'Position',[x0 y0],...					'VerticalAlignment', 'top',...					'HorizontalAlignment', 'center') ;end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?