## add label to a contour when when multiples plots

### Beatriz Sanchez (view profile)

on 18 Sep 2019 at 17:48
Latest activity Commented on by Star Strider

### Star Strider (view profile)

on 19 Sep 2019 at 19:19

### Star Strider (view profile)

Hello saviors,
so, I'm creating three contour from trhee matrix array on a single plot using hold on:
hold on
contour (muvec, muvec, spaln(:,:,1))
contour (muvec, muvec, spaln(:,:,2))
contour (muvec, muvec, spaln(:,:,3))
hold off
What I want is to label each contour with 1, 2, 3 for each matrix, so I can know which contour represent wich matrix array.
thank you all

R2019b

### Star Strider (view profile)

on 18 Sep 2019 at 18:02

They appear to be plotted on the same set of coordinate matrices. One option is to use different line colours (and other variations) for each contour plot. You might also consider contour3, that will allow you to separate them vertically.

Show 1 older comment
Star Strider

### Star Strider (view profile)

on 18 Sep 2019 at 20:12
My pleasure.
I would use different colours, and label them in the legend.
As I mentioned, you can also plot the contour outputs as planes with constant offsets between the planes. You would have to get the (x,y) data from each call to the contour function for that, and add your own z vectors to to each one offset them.
Example Code —
M1 = peaks;
[X,Y] = meshgrid((1:49)*pi/25);
M2 = sin(X) .* cos(Y);
[H1,C1] = contour(M1);
L1 = C1.LevelList;
Lv1 = ismember(H1(1,:), L1);
H1p = H1;
H1p(:,Lv1) = NaN;
[H2,C2] = contour(M2);
L2 = C2.LevelList;
Lv2 = ismember(H2(1,:), L2);
H2p = H2;
H2p(:,Lv2) = NaN;
figure
plot3(H1p(1,:), H1p(2,:), ones(size(H1p(1,:)))*1)
hold on
plot3(H2p(1,:), H2p(2,:), ones(size(H2p(1,:)))*4)
hold off
grid on
zlim([0 5])
text([0; 0], [0; 0], [1; 4], {'Contour 1','Contour 2'})
Example Plot —
Experiment to get the result you want.
Beatriz Sanchez

### Beatriz Sanchez (view profile)

on 19 Sep 2019 at 18:48
thank you, I didn't do it exactly like you, but your way help me a lot!
Star Strider

### Star Strider (view profile)

on 19 Sep 2019 at 19:19
As always, my pleasure!