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
0 个评论
采纳的回答
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);
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!