How can I show the contour plot of two functions in a graph?

4 次查看(过去 30 天)
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')

采纳的回答

Star Strider
Star Strider 2015-9-24
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 个评论
T de Vries
T de Vries 2020-6-14
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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Contour Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by