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

 Réponse acceptée

Grzegorz Knor
Grzegorz Knor le 22 Oct 2011
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

Plus de réponses (1)

Andi Rusdin
Andi Rusdin le 24 Oct 2011

0 votes

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 commentaire

Grzegorz Knor
Grzegorz Knor le 25 Oct 2011
Try:
s = xlabel('my xlabel');
set(s,'Units','normalized','Position',[0.5 -0.1])

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by