How can I superimpose a contour with geoshow

3 visualizzazioni (ultimi 30 giorni)
Anton
Anton il 12 Mar 2017
Modificato: Anton il 17 Mar 2017
What I was trying to accomplish to here was to plot the contour over a worldmap but when I run it, the map doesn't even show up. Is there a way to plot contours over top of a map? The portion of concern is contour. It models a hurricane and I would like to put the map of the part of the world that it crosses over behind it.
scrsz = get(0,'ScreenSize');
fig=figure('OuterPosition',[scrsz(1) scrsz(2) scrsz(3) scrsz(4)],'units','normalized','outerposition',[0 0 1 1]);
for j=1:length(T)
Xmax = max(Xc);
Xmin = min(Xc);
Ymax = max(Yc);
Ymin = min(Yc);
Xrange = linspace(Xmin,Xmax,53);
Yrange = linspace(Ymin,Ymax,53);
[X,Y] = meshgrid(Xrange*2,Yrange*1.5);
Ux2 = Ux1(j)+ (CL(j)/(2*pi))*(Y-Yc(j))./((X-Xc(j)).^2+(Y-Yc(j)).^2);
Vy2 = Vy1(j)- (CL(j)/(2*pi))*(X-Xc(j))./((X-Xc(j)).^2+(Y-Yc(j)).^2);
Utot = sqrt(Ux2.^2+Vy2.^2);
%bx = worldmap(latLim,longLim);
% set(bx, 'Visible', 'off')
% states = shaperead('usastatehi','UseGeoCoords', true);
% land = shaperead('landareas','UseGeoCoords',true)
% geoshow(bx,land,'FaceColor','g') %Shows land other than USA%
% geoshow(bx, states, 'FaceColor', 'g') %Divides USA into states%
[c,h]=contourf(X,Y,Utot,400);
filename='Sandy.gif';
set(h,'LineStyle', 'none')
% hold on
% plot(Dx,Dy,'LineStyle','none','Marker','o','MarkerEdgeColor','r','MarkerFaceColor','r','MarkerSize',5)
% hold off
drawnow % Draw the plot now (not at when the loop is done) %
movTVC=getframe(fig);
im = frame2im(movTVC);
[imind,cm] = rgb2ind(im,256);
if j == 1;
imwrite(imind,cm,filename,'gif', 'Loopcount',inf,'DelayTime',0.1);
else
imwrite(imind,cm,filename,'gif','WriteMode','append','DelayTime',0.1);
end
pause(10^-6);
set(h,{'Visible'},{'off'})
if j==length(T)
set(h,{'Visible'},{'on'})
else
set(h,{'Visible'},{'off'})
end
end
%close(fig) % Close the figure at the end %
  4 Commenti
Chad Greene
Chad Greene il 16 Mar 2017
The new example you provided is not a working one, because we don't have your data. Nor is the example very minimal. It's also not clear whether the problem regards contouring or a missing plot. The missing plot may be related to this line:
set(ax, 'Visible', 'off')
Anton
Anton il 17 Mar 2017
Modificato: Anton il 17 Mar 2017
I will adjust the code so that only the relevant parts are showing. Ultimately, I want to plot a map of the USA behind the contour on the same plot and be able to see the hurricane fly over the map. the line
set(ax, 'Visible', 'off')
is for the previous plot of the map which is irrelevant to the contour. The section
%bx = worldmap(latLim,longLim);
% set(bx, 'Visible', 'off')
% states = shaperead('usastatehi','UseGeoCoords', true);
% land = shaperead('landareas','UseGeoCoords',true)
% geoshow(bx,land,'FaceColor','g') %Shows land other than USA%
% geoshow(bx, states, 'FaceColor', 'g') %Divides USA into states%
[c,h]=contourf(X,Y,Utot,400);
filename='Sandy.gif';
set(h,'LineStyle', 'none')
% hold on
% plot(Dx,Dy,'LineStyle','none','Marker','o','MarkerEdgeColor','r','MarkerFaceColor','r','MarkerSize',5)
% hold off
is where I was attempting to do this

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Contour Plots 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