How to superpose pcolor and plot on the same figure?

50 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

TADA
TADA il 29 Giu 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);
  1 Commento
A LL
A LL il 29 Giu 2021
Thank you TADA!
I thought since the clf command was before the plot and pcolor command, it would still work (clearly not!).

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Lighting, Transparency, and Shading in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by