How can I show the contour plot of two functions in a graph?
13 次查看(过去 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')
0 个评论
采纳的回答
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
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 Center 和 File Exchange 中查找有关 Contour Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!