How to superpose pcolor and plot on the same figure?
26 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
TADA
le 29 Juin 2021
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);
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Animation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!