Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MATLAB Fill area between two contour plots

I have two contour plots and I want to be able to fill from one contour in one image to the same height contour in the other.

enter image description here

In the plot you can see two lines of each color - these are the lines I want to fill between, with the same color as the lines (though preferably translucent). The code for these are as follows

test = repmat(repelem(0:6,2),10,1);
test1 = test(:,2:end-1);
test2 = test(:,1:end-2);
contour(test1,1:5);
hold on;
contour(test2,1:5);

I did think that maybe I could create another image that has the desired height at each bin and do some kind of contourf, but that could be a problem if in future the lines cross over, which they may well do. In that case, I'd like the area they cross to be a combination of the colors that are crossing over.

like image 420
user1153070 Avatar asked Nov 07 '22 20:11

user1153070


1 Answers

Have you try using ```fill``?

% test values
col = 'g';
x1=[6 6 6];y1=[1 5 10]; x2= [7 7 7];

x2 = [x1, fliplr(x2)];
inBetween = [y1, fliplr(y1)];
fill(x2, inBetween, col);
like image 131
lhoupert Avatar answered Nov 15 '22 08:11

lhoupert