How to plot more lines of xtick label

35 views (last 30 days)
Xiang yu Wang
Xiang yu Wang on 16 May 2019
Answered: Liviu Ivanescu on 17 Nov 2020
QQ截图20190516174459.png
xtick label in figure above is some imformation of a satellite with function 'text';
however it's difficult to adjust position 2nd, 3rd,and so on lines of xticklabel using function 'text';
so is there anyway to add multiple lines of xtick label without function 'text'?

Accepted Answer

Luna
Luna on 16 May 2019
Edited: Luna on 16 May 2019
Hi,
Have you tried this function from FEX?
  3 Comments

Sign in to comment.

More Answers (1)

Liviu Ivanescu
Liviu Ivanescu on 17 Nov 2020
Try this:
xtick = get(gca,'XTick');
row1 = compose('%3.1f',lat(xtick));
row2 = compose('%3.1f',lon(xtick));
labelArray = [row1; row2];
tickLabels = strtrim(sprintf('%s\\newline%s\n', labelArray{:}));
set(gca,'XTickLabel',tickLabels);
xlabel('Latitude/Longitude (deg)')

Community Treasure Hunt

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

Start Hunting!

Translated by