How can I superimpose a contour with geoshow
3 views (last 30 days)
Show older comments
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 Comments
Chad Greene
on 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')
Answers (0)
See Also
Categories
Find more on Contour Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!