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

create your own colorbar using surf or patch
can you explain a bit more how ?
Bad idea about surf and patch. BUt you can modify existing colorbar

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

답변 (1개)

darova
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])

카테고리

질문:

2020년 6월 4일

답변:

2020년 6월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by