how to conver to 3d plot to 2d plot well?

조회 수: 138 (최근 30일)
Sierra
Sierra 2022년 5월 21일
답변: Voss 2022년 5월 21일
i know how to convert to 3d to 2d plot
first, 3d plot has three axes but if you convert 3d to 2d, it only has two axes.
so what i'm asking is that how to conver to 3d plot to 2d plot with three infrmation(x,y,z)?
ex) i have longitude, latitude and altitude data. and i want to plot this data well with 2d plot
thanks!

채택된 답변

Voss
Voss 2022년 5월 21일
You could make a 2d plot of some kind whose color comes from the data in the 3rd dimension, e.g., a surface or a contour:
lat = -50:5:50;
long = -100:5:100;
altitude = 6000-sqrt(lat(:).^2+long.^2);
% first, a 3d scatter plot:
subplot(3,1,1)
[x,y] = meshgrid(long,lat);
scatter3(x(:),y(:),altitude(:));
xlabel('Longitude');
ylabel('Latitude');
zlabel('Altitude');
% second, a surface of the same data,
% colored according to altitude:
subplot(3,1,2)
surface(long,lat,altitude)
xlabel('Longitude');
ylabel('Latitude');
cb = colorbar();
cb.YLabel.String = 'Altitude';
% third, a filled contour of the same data,
% colored according to altitude:
subplot(3,1,3)
contourf(long,lat,altitude)
xlabel('Longitude');
ylabel('Latitude');
cb = colorbar();
cb.YLabel.String = 'Altitude';

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Colorbar에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by