- Plot Temperature Data on a Geographic Map: Use "geoshow" or another geographic plotting function to display your temperature data on a map. This ensures the plot is in a geographic context.
- Overlay Lightning Data: On the same geographic plot, overlay your lightning data using "geodensityplot".
How to combine pcolor map to geodensityplot map?
1 次查看(过去 30 天)
显示 更早的评论
I wanted to combine the lightning data and temperature data into one map, I was trying to combine the pcolor map and geodensityplot map. However, it showed that :
Error using geodensity plot, adding Geographics to Axes is not supported.
Then I looked through other solutions in the Community and it seemed not applicable for my case. May I know what can I do? Thank you very much.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/792894/image.png)
My code was:
ncdisp("temp.nc")
lat=ncread("temp.nc","lat")
lon=ncread("temp.nc","lon")
temp=ncread("temp.nc","dpt")
temp1=temp(:,:,145)
map=pcolor(lon,lat,temp1)
map.EdgeAlpha=0
colorbar
caxis([223 323])
load Lightning_WWLLN_201701
mix=[lightning.lat lightning.lon]
mix(lightning.lat<18 | lightning.lat>45 | lightning.lon<90 | lightning.lon>130,:)=[]
hold on
geodensityplot(mix(:,1),mix(:,2),'FaceColor','interp')
colorbar
0 个评论
回答(1 个)
Abhinaya Kennedy
2024-4-4
Hey,
To combine lightning data and temperature data into one map and avoid the error you're encountering, you should use a geographic plotting function for both datasets instead of mixing Cartesian plotting "pcolor" with geographic plotting "geodensityplot". Here's a simplified approach:
Here's a short example:
% Load temperature data
lat = ncread("temp.nc", "lat");
lon = ncread("temp.nc", "lon");
temp = ncread("temp.nc", "dpt");
temp1 = temp(:,:,145);
% Create a geographic map for temperature data
figure;
worldmap('World');
geoshow(lat, lon, temp1, 'DisplayType', 'texturemap');
caxis([223 323]); % Adjust temperature range
colorbar;
% Load and overlay lightning data
load Lightning_WWLLN_201701; % Assuming this loads lightning data
mix = [lightning.lat, lightning.lon];
geodensityplot(mix(:,1), mix(:,2), 'FaceColor', 'interp');
colorbar;
This approach keeps everything within a geographic plotting context, avoiding the error you encountered.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Geographic Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!