How can I show the contour plot of two functions in a graph?
9 views (last 30 days)
Show older comments
I have two contour plots below. I would like to show in the same graph both "contours.
How should I proceed?
Thanks.
x = linspace(-10,10);
y = linspace(-10,10);
[X,Y] = meshgrid(x,y);
Z = X.^2+Y.^2;
figure
contour(X,Y,Z, 'ShowText','on')
x = linspace(-10,10);
y = linspace(-10,10);
[X,Y] = meshgrid(x,y);
Z = X +Y;
figure
contour(X,Y,Z, 'ShowText','on')
0 Comments
Accepted Answer
Star Strider
on 24 Sep 2015
See if this does what you want:
x = linspace(-10,10);
y = linspace(-10,10);
[X,Y] = meshgrid(x,y);
Z = X.^2+Y.^2;
figure
contour(X,Y,Z, 'ShowText','on')
Z = X +Y;
hold on
contour(X,Y,Z, 'ShowText','on')
hold off
Use the hold function to make multiple plots on one set of axes.
3 Comments
T de Vries
on 14 Jun 2020
Dear Star Strider,
Hopefully, you or someone else, can help me.
I want to make a figure that plots two (and more) contourf plots in the same figure.
For this I used the hold on and hold off as mentioned above, but this is not working unfornutately. Can someone help me?
Kind regards,
Tessa
More Answers (0)
See Also
Categories
Find more on Contour Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!