wrap and center justify axes and tick label

I have been tried to get text wrapping and center justifying axes and ticklabel, I tried textwrap and uicontrol and so on but seen not work. can you teach me how to do that

 Accepted Answer

Analyze this example:
plot(1:5)
xTick = 1:5;
set(gca,'xtick',xTick)
yTick = get(gca,'ytick');
set(gca,'xticklabel',[])
xTickLabel = {{'first';'label'},'second',{'third';'label'},'long fourth tick label ','fifth'};
for k = 1:length(xTick)
text(xTick(k),yTick(1)-0.05*(yTick(end)-yTick(1)),xTickLabel{k},'HorizontalAlignment','center')
end

More Answers (1)

i have one more question. how to expand plot windows below the xticklabel so i can put X label below the tick label.
thanks

1 Comment

Try:
s = xlabel('my xlabel');
set(s,'Units','normalized','Position',[0.5 -0.1])

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!