Plot Contour Map Over a plot Map
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Walter Roberson
2012년 8월 19일
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
Alfred Ruff
2021년 3월 30일
편집: Alfred Ruff
2021년 3월 30일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!