필터 지우기
필터 지우기

How to set colorbar seperately for subplot?

조회 수: 6 (최근 30일)
Genhou
Genhou 2017년 11월 13일
댓글: KL 2017년 11월 14일
Dear all,
I am frustrated when I trying to setup colorbars separaterly for the subplots in one figure. I will be appreciate for any help.
The difficult is that I trying to give a independent colorbar to each subplot. It is much easier for the matlab 2012 and earlier, but it is much complex for the matlab 2016, which I am using now.
The problem is that it seems the colorbar of subplot 1 does not belong to subplot 1. If I change the range of colorbar of subplot 1, then the ranges of other colorbar change as well. So my question is how to set the colorbar so that the colorbar of one subplot ONLY impacts on the subplot and not on the others? By the way, the range of each subpplot is different that of the other.

채택된 답변

KL
KL 2017년 11월 13일
Try using handles, that way you have control over which colorbar you're accessing,
[X,Y] = meshgrid(-5:.5:5);
Z = X.^2 + Y.^2;
figure
subplot(2,1,1)
h1 = surf(Z);
c1 = colorbar;
c1.Limits = [20 50];
subplot(2,1,2)
h2 = surf(peaks);
c2 = colorbar;
c2.Limits = [-6 8];
  댓글 수: 4
Genhou
Genhou 2017년 11월 14일
The version is Matlab 2015b. Maybe I should update to the latest version of matlab.
KL
KL 2017년 11월 14일
That's strange, I tested it on a 2015a version and it still works fine. Do not try it on your actual program, just try this piece of code and see if the same thing occurs?

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!