How to plot more lines of xtick label

24 次查看(过去 30 天)
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'?

采纳的回答

Luna
Luna 2019-5-16
编辑:Luna 2019-5-16
Hi,
Have you tried this function from FEX?
  3 个评论
Yisrael Loecher
Yisrael Loecher 2020-5-12
编辑:Yisrael Loecher 2020-5-12
I also am using this function, and it works quite well. You may need to use mat2cell to set up the xTicks properly which is passed as an arg as I needed to do, but it is do-able. Thank you for this function.

请先登录,再进行评论。

更多回答(1 个)

Liviu Ivanescu
Liviu Ivanescu 2020-11-17
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)')

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by