MATLAB: Center text on screen center Very basic question, but how can I (exactly) center text on screen (or figure window)? If I just use text(.5,.5,'x'); axis off the x is not centered on screen. Best Answer % put a small x in the center of a new figurefigure('menubar','none') ;ah = gca ;th = text(1,1,'X') ;set(ah,'visible','off','xlim',[0 2],'ylim',[0 2],'Position',[0 0 1 1]) ;set(th,'visible','on','HorizontalAlignment','center','VerticalAlignment','middle') Related SolutionsMATLAB: Is there a way to lower the XTickLabels a little aH = axes;plot(rand(10,1));xCoord = get(aH,'Xtick');yCoord = get(aH,'YLim');yCoord(2) = [];offset = 0.05; %How far from the axes, in axes unitsyCoord = yCoord-offset;set(aH,'XTickLabel',[]); %Comment out this line to see where the old ticks werefor ii = xCoord text(ii,yCoord,num2str(ii),... 'HorizontalAlignment','center',... 'VerticalAlignment','middle');end MATLAB: Automatically Position Text Annotations on a plot. ylim=get(gca,'ylim');xlim=get(gca,'xlim')text(xlim(1),ylim(2),'yourtext') Related QuestionProgrammatically calculate position for textbox (annotation)How to remove the blue toolbar around the MATLAB figure.Too many non-property/value arguments error occurred when applying a text box to a figure
Best Answer