How to force the colorbar to adopt n values?

조회 수: 9 (최근 30일)
Daniëlle Nijhof
Daniëlle Nijhof 2017년 11월 21일
댓글: Daniëlle Nijhof 2017년 11월 22일
Hi everyone,
I've made a 3x3 subplot using pcolor. The colorbars of the left and right columns of the plot adopt three values, i.e. 60, 65 and 70. I would like the colorbars of the center column to adopt three values as well, i.e. 62, 67 and 72, instead of six values as it is now.
Can someone help me out?
  댓글 수: 2
Greg
Greg 2017년 11월 21일
I think you're looking for caxis().
Daniëlle Nijhof
Daniëlle Nijhof 2017년 11월 21일
Hi Greg,
For this plot, caxis is set to caxis([min max]), as I want to show only a range of 12 dB. However, I want to set the range with caxis([min max]) and then force only three values to appear on the colorbar.

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

채택된 답변

KL
KL 2017년 11월 21일
편집: Walter Roberson 2017년 11월 21일
Always use a handle,
When you create a colorbar, do it like,
c{1,1} = colorbar;
c{1,1}.Ticks = [60 65 70];
do it for all 9 subplots and you can control your colorbars just by accessing its index.
  댓글 수: 1
Daniëlle Nijhof
Daniëlle Nijhof 2017년 11월 21일
Hi KL,
This works!
Thank you very much :-)

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

추가 답변 (1개)

Image Analyst
Image Analyst 2017년 11월 21일
Try this:
colormap(jet(256)) % Use 256 colors.
caxis([62, 72]);
c = colorbar % Get handle to colorbar
c.Ticks = [62,67,72] % Set tick values.
  댓글 수: 1
Daniëlle Nijhof
Daniëlle Nijhof 2017년 11월 22일
This also works! Thank you Image Analyst :-)

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by