How can one remove y-axis ticks on imagesc but keep labels?

8 ビュー (過去 30 日間)
Birgit Strikholm
Birgit Strikholm 2019 年 2 月 1 日
編集済み: Birgit Strikholm 2019 年 2 月 1 日
While heatmapping my data with imagesc, I want to display on my x-axis ticks and labels, but on y-axis I only want to display labels, no ticks. I know one can remove all ticks by setting the length to zero with set(gca,'TickLength',[0 0]). But how to achieve this on only one axis?
  3 件のコメント
Birgit Strikholm
Birgit Strikholm 2019 年 2 月 1 日
Umm, in my case this removes everything, both ticks and labels. Need labels. :)
madhan ravi
madhan ravi 2019 年 2 月 1 日
oh ok normally it worked but didn‘t test with imagesc()

サインインしてコメントする。

採用された回答

Adam
Adam 2019 年 2 月 1 日
hAxes.YAxis.TickLength = [0 0];
Following on from what you said in your own question. That seems to work. Assuming you are in a sufficiently recent version of Matlab. You didn't give your version.
  1 件のコメント
Birgit Strikholm
Birgit Strikholm 2019 年 2 月 1 日
編集済み: Birgit Strikholm 2019 年 2 月 1 日
Thanks, I shall look into this. I'm on 2018b. Being somewhat a novice to the whole graphics thing I still need to figure where and how exactly does one set all these properties. Given this figure also has double axes (trying to seemingly shift x-ticklabels to appear inbetween tickmarks via an additional invisible axis) ... it all just overwhelmed me for a sec.
Edit: Yup, that will do the trick. A simple example to those who might also need to apply this:
C = [0 2 4 6; 8 10 12 14; 16 18 20 22];
ax1=gca;
imagesc(ax1,C);
%yticks([]); %does not work, wipes out labels as well
ax1.YAxis.TickLength = [0 0];

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by