How do I create a movie of ocean data with a constant land mask?

2 visualizaciones (últimos 30 días)
I want to make a movie of some ocean data with a land mask as the background. I don’t want to keep drawing the same mask over and over, so the ideal thing to do is to plot the mask first, leave it there, then replace the new data with the old data at each time step. Also, I want the mask data and ocean data to have different colormaps, which I think means I need to use two different axes objects in the same figure. So, logically, I want to do something like:
figure
hold on
% Plot mask
hmaskax = axes; % handle to mask axes
plotmask(hmaskax); % I wrote plotmask, it calls pcolor(hmaskax, …)
colormap(hmaskax,gray)
% Plot data
data = getdata(t0);
hdataax = axes; % handle to data axes
hdataplot = plotdata(hdataax,data); % I wrote plotdata, it calls pcolor(hdataax, …)
colormap(hdataax,jet)
colorbar(hdataax)
hdataax.Position = hmaskax.Position; % to align mask and data
hdataax.Color = 'none'; % so mask shows through NaN data values
% Iterate
for t = t0:dt:tf
delete(hdataplot)
data = getdata(t);
hdataplot = plotdata(hdataax,data);
colorbar(hdataax)
hdataax.Position = hmaskax.Position; % to align mask and data
hdataax.Color = 'none'; % so mask shows through NaN data values
end
but this seems to create a new set of axes every time I call plotmask or plotdata, so clearly passing the axes handle is not working how I expected. What’s a better way to approach this? Should I be passing figure handles instead of axes handles? It might also be possible to avoid writing my own plotting functions entirely and just put all the code in the main function.

Respuestas (0)

Categorías

Más información sobre Lighting, Transparency, and Shading en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by