Increase levels on colorbar

조회 수: 74 (최근 30일)
Sultan
Sultan 2019년 11월 28일
편집: Sultan 2019년 11월 29일
Is there any way to increase or decrease the range of levels on the colorbar ? I plotted a spectrogram, I want to have more levels on the color bar. All I found that I can define the range of the colorbar but not its level. Like I want to have [-140:10:-40] levels but I cannot find any other solution. The image of the color bar is attachedColorbar.PNG
  댓글 수: 2
Adam
Adam 2019년 11월 28일
편집: Adam 2019년 11월 28일
What do you mean by 'levels'?
You can choose the size of your colourmap.
e.g.
cmap = parula( 1024 );
colormap( hAxes, cmap );
where hAxes is your axes handle. Or if you prefer an adhoc approach just
colormap( cmap )
to apply it to whatever is the currently selected axes.
Sultan
Sultan 2019년 11월 29일
Hi Adam,
Thanks for the tip. By levels I meant, that currently there is a difference of 20 between the values, I want to decrease this difference to like 5 or 2, so the next value after -40 I see is that of -45 or -42 all the way down to -140.

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

채택된 답변

Adam
Adam 2019년 11월 29일
If you create the colourbar and keep its handle, e.g
hColourbar = colorbar( hAxes );
then you can edit the properties of the colourbar, in particular the 'Ticks' property. Or you can just do it all in one go if you knnow beforehand:
colorbar( hAxes, 'Ticks', -140:2:40 )
although I imagine ticks every 2 samples would look a mess with the labels. Every 5 probably ok.
  댓글 수: 1
Sultan
Sultan 2019년 11월 29일
편집: Sultan 2019년 11월 29일
Yes exactly, thanks for the tip again. What I did, thought the other way round of changing using:
colorbar
I used the command:
h = colorbar;
set(h,'Ticks',[-140:20:-40])
it did the trick. In addition I got this colorbar from the limits of the colorbar itself:
level= get(h,'Limits');
set(h, 'Ticks', linspace(level(1),level(2),20));

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by