Combining Map with Surface Plot

26 vues (au cours des 30 derniers jours)
Evan Kutta
Evan Kutta le 21 Août 2015
Commenté : Evan Kutta le 21 Août 2015
I just acquired the Mapping Toolbox so that I could add maps to some figures I have made using Matlab.
Here is my working code to generate a crude (no titles or other extras for simplicity) 4 panel plot of my data
figure; set(subplot(2,2,1),'Position', [0.05, 0.55, 0.45, 0.4]); surf(Uwin,'EdgeColor','none');
set(gca, 'FontSize', 17); hold on;
set(subplot(2,2,2),'Position', [0.55, 0.55, 0.45, 0.4]); surf(Vwin,'EdgeColor','none');
set(gca, 'FontSize', 17); hold on;
set(subplot(2,2,3),'Position', [0.05, 0.05, 0.45, 0.4]); surf(Usum,'EdgeColor','none');
set(gca, 'FontSize', 17); hold on;
set(subplot(2,2,4),'Position', [0.55, 0.05, 0.45, 0.4]); surf(Vsum,'EdgeColor','none');
set(gca, 'FontSize', 17); hold off;
Here is working code to generate a 4-panel plot of the map I need
figure; set(subplot(2,2,1),'Position', [0.04, 0.56, 0.45, 0.5]); hold on;
coast=load('coast');
axesm('eqdcylin','origin',[0 180 0],'MapLatLimit',[0 90]); gridm on;
geoshow(coast.lat,coast.long, 'Color', 'black');
tightmap;
set(subplot(2,2,2),'Position', [0.54, 0.56, 0.45, 0.5]);
coast=load('coast');
axesm('eqdcylin','origin',[0 180 0],'MapLatLimit',[0 90]); gridm on;
geoshow(coast.lat,coast.long, 'Color', 'black'); tightmap;
set(subplot(2,2,3),'Position', [0.04, 0.07, 0.45, 0.5]);
coast=load('coast');
axesm('eqdcylin','origin',[0 180 0],'MapLatLimit',[0 90]); gridm on;
geoshow(coast.lat,coast.long, 'Color', 'black'); tightmap;
set(subplot(2,2,4),'Position', [0.54, 0.07, 0.45, 0.5]);
coast=load('coast');
axesm('eqdcylin','origin',[0 180 0],'MapLatLimit',[0 90]); gridm on;
geoshow(coast.lat,coast.long, 'Color', 'black'); tightmap; hold off;
What is the best way to get MATLAB to overlay my data over my map using MATLAB 2015a, while preserving the subplot (4-panel) structure?
Thank you very much, Evan Kutta

Réponse acceptée

Kelly Kearney
Kelly Kearney le 21 Août 2015
All the map plotting functions plot to the current axis, regardless of whether it's a subplot or not. So to plot to specific ones, either make sure your desired subplot is the current axis, or pass (... 'parent', mysubax) as properties.
Do you have coordinates to go along with your plotted arrays, or are you just assuming they fill the full global space? I'm assuming the latter in this example. Also, I cleaned up some of the unnecessary code (the limits and origin you specified are the defaults, and subplot is unnecessary when you're passing specific axes coordinates).
[Uwin, Vwin, Usum, Vsum] = deal(rand(50,100)); % placeholders for your data
lt = linspace(-90, 90, size(Uwin,1));
ln = linspace(-180, 180, size(Uwin,2));
data = {Uwin, Vwin, Usum, Vsum};
pos = [...
0.04, 0.56, 0.45, 0.5
0.54, 0.56, 0.45, 0.5
0.04, 0.07, 0.45, 0.5
0.54, 0.07, 0.45, 0.5];
for ii = 1:4
ax(ii) = axes('position', pos(ii,:));
axesm('eqdcylin');
gridm on;
surfm(lt, ln, data{ii});
geoshow(coast, 'color', 'k');
tightmap;
end
  1 commentaire
Evan Kutta
Evan Kutta le 21 Août 2015
Thank you very much, fixed my problem and helped me write cleaner code!

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by