필터 지우기
필터 지우기

Plotting 3D Heatmap/Surf using Lat, Lon, Pressure, and a fourth Variable

조회 수: 66 (최근 30일)
Ching An Yang
Ching An Yang 2023년 7월 27일
댓글: Ching An Yang 2023년 8월 4일
Hi,
I want to plot a 3D figure that looks like heatmap or surf map using Lat, Lon, Pressure as my X, Y, and Z, then colored by a fourth variable C.
The dimension of each variable is like this:
Lat : 1D, 100 x 1
Lon : 1D, 100 x 1
Pressure : 2D, 100 x 32
C : 2D, 100 x32
The problem with using Surf function is that the Z variable must be a matrix and have the same dimension as the X and Y, which I assume should be 100 x 100. Typically this means Z is a fuction of X and Y, or Z is uniform.
Here, my pressure is 100 x 32, but each pressure level for a Lat Lon location is different... Not only Pressure is not a function of Lat and Lon, Pressure itself is not uniform among all the Lat and Lon location.
I have plotted the 3D figure using scatter3, but I want to make a plot that similar to heatmap or surf map. How do I do this?
Thank you very much for your help!
  댓글 수: 2
Voss
Voss 2023년 7월 28일
Can you post the code you wrote that uses scatter3?
Ching An Yang
Ching An Yang 2023년 7월 28일
편집: Ching An Yang 2023년 7월 28일
I made my lat and lon as the same dimension as pressure and C, then plotted the flatten variables.
Lat_2D = ones(length(Lat),length(Pressure(1,:)));
Lat_2D = Lat_2D.*Lat;
Lon_2D = ones(length(Lon),length(Pressure(1,:)));
Lon_2D = Lon_2D.*Lon;
scatter3(Lat_2D(:),Lon_2D(:),Pressure(:)/100,8,C(:),'filled');
colorbar
set (gca,'Zdir','reverse')
xlabel("Latitude (°)")
ylabel("Longitude (°)")
zlabel("Pressure (hPa)")

댓글을 달려면 로그인하십시오.

답변 (1개)

Pratyush
Pratyush 2023년 8월 4일
I understand that you want to plot a 3D surface map of {Latitude, Longitude, Pressure}. Looking at the code you posted about scatter plot, I assume you have a pair {Lat(i), Lon(i)} maps to 32 different Pressure(i) values. You can plot a surf map using the following code:
% make 32 duplicate columns of Lat and Lon
Lat = repmat(Lat,32,1);
Lon = repmat(Lon,32,1);
% Plot surf map
surf(Lat, Lon, Pressure, C);
  댓글 수: 1
Ching An Yang
Ching An Yang 2023년 8월 4일
Thank you! That would work but it doesn't come out to be what I imagined... I wonder if my plot is shattered instead of having surfaces becuase of my Pressure values are not uniform?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by