File Exchange

image thumbnail


version 1.0 (1.89 KB) by

Replaces XTickLabels with "normal" texts accepting multiline texts and TEX interpreting



View License

MY_XTICKLABELS replaces XTickLabels with "normal" texts accepting multiline texts and TEX interpreting and shrinks the axis to fit the texts in the window.

Comments and Ratings (18)


BK (view profile)

Then subsequent code should look like:
ht(ii) = text('String',xtickstring{ii}, ...
'Units','data', ...
'VerticalAlignment', 'top', ...
'HorizontalAlignment', 'center ', ...
'Position',[xtickpos(ii) Ybot], ...
'Tag','MUXTL', 'Parent', Ha);

It seems that I have found a bug at line 54:

In the code:
Ybot = min(get(gca,'YLim'));

I changed it to:
Ybot = min(get(Ha,'YLim'));

Liaofan Lin


dzq (view profile)

Tanks! You're a good guy.

Very nice, thanks for posting this


craq (view profile)

This is a very useful tool. One suggestion though: the text() command gets confused if there is more than one axis, so maybe you can set the current axis to Ha with axes(Ha) before the cell '%% Make XTickLabels'.

Du Xiao

Perfect, Thank you very much for your help!

Works for the most part. Manageable issue: labels remain in same figure positions when changing the axis using axis(xylims) rather than moving to the new correct locations relative to the axes. Solution for now is of course to only call my_xticklabels after axis limits have been set.

Dominik Bach

After switching to (R2009a), the squeeze axes part of the function does not work any more. Converting the axes units to pixels produces negative values for some reason, hence the function crashes. Otherwise still very helpful.

Wilbert Zarco

It solves the 'xticklabels' limitation of lacking Tex capabilities, and I think also the work for the matlab team to implementing it. Great job!

Claude Mueller

worked great for me! thanks!!

Bob Farrell

Perfect. Just what I was looking for. It does what it says and was a drop-in into my code. I needed multi-line xtick labels, and the TEX characters were a bonus.

MATLAB Release
MATLAB 7.5 (R2007b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video