필터 지우기
필터 지우기

rotating x-axis labels on an image

조회 수: 1 (최근 30일)
Laszlo Bodnar
Laszlo Bodnar 2016년 2월 25일
댓글: Laszlo Bodnar 2016년 2월 26일
I have created an image using the following code:
smallmatrix_6partic=[0 1 0 0 0 0 ; 0 0 0 0 0 0 ; 0 1 0 0 0 0 ; 0 1 0 0 0 0; 0 0 0 1 0 0; 0 0 0 0 1 0];
smallmatrix_colheading= {'A','B','C','D','E','F','G'}; % these are going to be the row headings of the matrix
[rows,cols]=size(smallmatrix_6partic);
imagesc(smallmatrix_6partic)
set(gca,'Xtick',1:rows,'XTickLabel',smallmatrix_colheading)
set(gca,'Ytick',1:rows,'YTickLabel',smallmatrix_colheading)
My question is, is there a way to change the alignment and rotate the x-axis labels (A, B, C, etc...), maybe 90 degrees clockwise?

채택된 답변

Sean de Wolski
Sean de Wolski 2016년 2월 25일
In R2014b or newer:
>> set(gca,'XTickLabelRotation',90)
  댓글 수: 2
Laszlo Bodnar
Laszlo Bodnar 2016년 2월 25일
Awesome, thank you so much for the quick response, Sean!
Laszlo Bodnar
Laszlo Bodnar 2016년 2월 26일
One additional comment. Since I use MatLab2014a the above function did not work for me in the end. I searched couple of sites and ultimately found Ben Tordoff's solution. By applying
rotateXLabels(gca(),90)
I got what I needed. But of course I will keep your answer in mind so when we will update to version 2014b I could use it. Thank you again.

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

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by