How to superpose pcolor and plot on the same figure?

26 次查看(过去 30 天)
I try to superpose points with plot on pcolor and I only get the plot or the pcolor which is the furthest in the code lines.
I try to switch orders but I can't find the right way to get the points of plot and the pcolor on the same figure.
Refer to figure matlab_fig1.fig for the plot command and to matlab_fig2.fig for the pcolor command.
Here is my code:
figure(1)
hold on;
colormap(jet);
clf;
plot(xdomain,ydomain,'r+'); % refer to --> matlab_fig1.fig DOES NOT APPEAR
pcolor(diff); % refer to --> matlab_fig2.fig I ONLY GET THIS LINE
colorbar;
caxis([-1, 1]);
colorbar('Ticks',[-1,0,1]);
shading flat;
figure(gcf);
Thank you

采纳的回答

TADA
TADA 2021-6-29
You call clf() after changing hold status to 'on'
this clears your figure, therefore resets your hold status to 'off'.
move clf() before your hold on; statement:
figure(1)
clf;
hold on;
colormap(jet);
plot(xdomain,ydomain,'r+'); % refer to --> matlab_fig1.fig DOES NOT APPEAR
pcolor(diff); % refer to --> matlab_fig2.fig I ONLY GET THIS LINE
colorbar;
caxis([-1, 1]);
colorbar('Ticks',[-1,0,1]);
shading flat;
figure(gcf);
  1 个评论
A LL
A LL 2021-6-29
Thank you TADA!
I thought since the clf command was before the plot and pcolor command, it would still work (clearly not!).

请先登录,再进行评论。

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by