Customize ticks on colorbar

조회 수: 1 (최근 30일)
Magnus Myhre
Magnus Myhre 2018년 2월 15일
답변: Walter Roberson 2018년 2월 15일
Hey, I'm trying to customize my colorbar, in MATLAB. Where i would like my colorbar to have distinct boarders between each value.
i've tried
c=colorbar('yticklabel',{'PP', 'PP+DF', 'DF', 'DF+RG', 'DF+FC','PPgp','RG', 'MF+RG', 'RG+FC', 'FC', 'FC+DH', 'DH', 'MF', 'MF+DH','MF+FC'});
and
c=colorbar
set(c,'yticklabel',{'PP', 'PP+DF', 'DF', 'DF+RG', 'DF+FC','PPgp','RG', 'MF+RG', 'RG+FC', 'FC', 'FC+DH', 'DH', 'MF', 'MF+DH','MF+FC'});
which obviously does the exact same thing. When i run the script the colorbar, appear with no distinct "boarder" - and i only get 7 of the labels to appear next to the colorbar, where i would like to get all of them to appear, all with their own distinct color.
All help would by appreciated!:)
  댓글 수: 1
Adam
Adam 2018년 2월 15일
편집: Adam 2018년 2월 15일
You need to change the YTick as well as the label. It will only use as many labels as there are ticks. If there were more ticks than labels it would just cycle round the labels.

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

답변 (1개)

Walter Roberson
Walter Roberson 2018년 2월 15일
To get lines between the sections you need to turn Grid on. That is possible in r2014a and earlier but at the moment I do not recall if it can be done with later versions (which are implemented differently)

카테고리

Help CenterFile Exchange에서 Colorbar에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by