how to plot 2 colorbars from same set of data in contourf
이전 댓글 표시
I have a contourf plot using a single set of data consisting of both positive and negative values.
I would like to plot two separate colorbars to easily distinguish between the positive and negative values (I assume this would require some conditional statement). I would like to have the 0 values of data in white, negative values in blue scale and positive values in red scale. Basically, similar to that shown in the figure.
Any ideas on how this can be done? I've looked through the forum but I can't seem to find something related to two color bars from the same set of data.

댓글 수: 3
darova
2020년 6월 13일
create your own colorbar using surf or patch
Jacqueline Mifsud
2020년 6월 13일
darova
2020년 6월 13일
Bad idea about surf and patch. BUt you can modify existing colorbar
답변 (1개)
darova
2020년 6월 13일
- Create one more colorbar using copyobj
- Modify colorbars using set function
clc,clear
clf
[x,y,z] = peaks(50);
surf(x,y,z)
h = colorbar('location','north');
h1 = copyobj(h,gcf);
set(h,'position',[0.05 0.85 0.4 0.05])
set(h,'xlim',[2 5])
set(h1,'position',[0.55 0.85 0.4 0.05])
set(h1,'xlim',[-5 -2])

카테고리
도움말 센터 및 File Exchange에서 Colorbar에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!