How to plot a filled contour on a map plot?
20 views (last 30 days)
Show older comments
I'm working on a project where I need to plot a filled contour onto a map. Ideally, this contour plot would be partially transparent so that the map underneath can still be seen. I was previously having issues where matlab didn't like plotting the output from countourf onto a geomap, so I implemented the solution found here:
This, however, only gives the contour lines, and not the filled areas. I also tried using a mapplot, but I have other data that also needs to be on this figure and that didn't end up working.
Here is the function I used, getContourLineCoordinates:
and here is my current code:
geoscatter(points,"y","x","filled","MarkerFaceColor","#0000ff")
for m=1:length(shapes)
geoplot(shapes(m))
end
%plotting contour map from previous calculation
contdata = contourc(xrange,yrange,Ftotnorm',100);
cTbl = getContourLineCoordinates(contdata); % from the file exchange
% Plot contour lines
hold(ax,'on')
nContours = max(cTbl.Group);
colors = autumn(nContours);
for i = 1:nContours
gidx = cTbl.Group == i;
geoplot(ax, cTbl.Y(gidx), cTbl.X(gidx),'Color', colors(i,:)); % note: x & y switched
end
% Add colorbar
colormap("autumn")
colorbar(ax)
3 Comments
Star Strider
on 24 Dec 2023
I delete my unaccepted answers. You don’t seem to have used my solution anyway.
Accepted Answer
More 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!