Plot Contour Map Over a plot Map
2 views (last 30 days)
Show older comments
I'm trying to plot a counter map over a general map (Asia or US).
Generally speaking (input data is only by example)
% Data Input
long = (:,1)
lat = (:,2)
z = (:,3)
[x,y] = meshgrid(x,y)
z = x.^2 + y.^2
[C, h] = contour(x, y, z, 10)
clabel(C,h)
So this where I get stuck. I use world map 'asia' but
I only see the map and not the contour map over Asia.
Thanks,
Amanda
0 Comments
Answers (1)
Walter Roberson
on 19 Aug 2012
How are you doing the map plotting? If you are using the Mapping Toolbox, then you can use "hold on" and you would use contourm() to do the contour plot.
If you are using the third party mapping routines, then no solution was found when someone tried this about a month ago (which does not mean it is impossible, but does mean that it was not obvious to the level of resources that the volunteers could devote to it at the time.)
2 Comments
Alfred Ruff
on 30 Mar 2021
Edited: Alfred Ruff
on 30 Mar 2021
Hi Walter,
I've been having an issue with the same problem here, i have got the mapping toobox however i seem to be getting an error regarding the Group being a child of the plotted GeographicAxes.
I have attached my code so you can see it clearly:
close all; clc; clear all;
lat = [51.0059, 51.5055, 51.1613, 51.2012, 51.0864, 51.8603, 51.5028, 52.0796, 52.1480, 52.0629, 52.2426, 51.4050]';%latitude%
lon = [-2.6415, -2.7153, -1.7532, -1.8044, -3.6077, -1.6915, -1.9909, -2.8010, -2.0398, -3.6134, -2.8845, -3.4395]';%longitude%
lon0 = min(lon) ; lon1 = max(lon) ;
lat0 = min(lat) ; lat1 = max(lat) ;
latlim=[lat0 lat1]; lonlim=[lon0 lon1] ;
geoplot(lat,lon,'o','MarkerEdgeColor','k','MarkerFaceColor','k','MarkerSize',7)
geobasemap 'bluegreen'
hold on ;
lat = [51.0059, 51.5055, 51.1613, 51.2012, 51.0864, 51.8603, 51.5028, 52.0796, 52.1480, 52.0629, 52.2426, 51.4050]';%latitude%
lon = [-2.6415, -2.7153, -1.7532, -1.8044, -3.6077, -1.6915, -1.9909, -2.8010, -2.0398, -3.6134, -2.8845, -3.4395]';%longitude%
wind = [7.874234787, 11.14880444, 9.070286203, 6.905750214, 8.997209481, 10.32499084, 7.954392452, 4.712524199, 6.615710623, 6.970612345, 5.968275285, 8.997209481]';%mean wind speed%
lon0 = min(lon) ; lon1 = max(lon) ;
lat0 = min(lat) ; lat1 = max(lat) ;
latlim=[lat0 lat1]; lonlim=[lon0 lon1] ;
lon0 = min(lon) ; lon1 = max(lon) ;
lat0 = min(lat) ; lat1 = max(lat) ;
N = 20 ;
x = linspace(lon0,lon1,N) ;
y = linspace(lat0,lat1,N) ;
[X,Y] = meshgrid(x,y) ;
F = scatteredInterpolant(lon,lat,wind) ;
Z = F(X,Y) ;
contourm(Y,X,Z,20)
hold off ;
%Run
%Error using hggroup
%Group cannot be a child of GeographicAxes.
%Error in internal.mapgraph.HGGroupAdapter (line 62)
% g = hggroup('Parent',ax);
%Error in internal.mapgraph.ContourGroup (line 282)
% h = h@internal.mapgraph.HGGroupAdapter(args{:});
%Error in internal.mapgraph.GeographicContourGroup (line 55)
% h = h@internal.mapgraph.ContourGroup(varargin{:});
%Error in contourm (line 111)
%h = internal.mapgraph.GeographicContourGroup(ax, Z, R, levelList);
Any advice would be appreciated, thank you in advance.
[ also would it be possible to use contourf() in this situation and increase the transparency of the contour to see the map underneath?]
Thank you once again,
Best regards,
Alfred
See Also
Categories
Find more on Data Distribution 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!