フィルターのクリア

How to combine pcolor map to geodensityplot map?

5 ビュー (過去 30 日間)
Chun Long Wong
Chun Long Wong 2021 年 11 月 7 日
回答済み: Abhinaya Kennedy 2024 年 4 月 4 日
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.
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

回答 (1 件)

Abhinaya Kennedy
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:
  1. 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.
  2. Overlay Lightning Data: On the same geographic plot, overlay your lightning data using "geodensityplot".
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.

カテゴリ

Help Center および File ExchangeGeographic Plots についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by