How to plot more lines of xtick label

조회 수: 26 (최근 30일)
Xiang yu Wang
Xiang yu Wang 2019년 5월 16일
답변: Liviu Ivanescu 2020년 11월 17일
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.
Luna
Luna 2020년 6월 1일
Your welcome! :)

댓글을 달려면 로그인하십시오.

추가 답변 (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