how to place a 2D section in 3d map?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Lilya
am 10 Feb. 2025
Beantwortet: Lilya
am 12 Feb. 2025
I have a section ot temperature data that want to place it in a 3D map
any help will be apprecited.
this is to plot the map
figure
surf(Xlon,Ylat,Zdep)
shading interp
Zlimit=[-2800 2800];
colormap(cmap)
dem1 = demcmap(Zlimit,128)
view(20,70);
axis([32 37 26 30 -2800 2800])
caxis([-2800 2800])
hold on
xlabel('Longitude [\circE]','fontsize',14)
ylabel('Latitude [\circN]','fontsize',14)
zlabel('Depth [m]','fontsize',14)
colorbar
% and this for the section:
pcolor(Xgrid2(:,xl),Zgrid(:,xl),chl(:,xl,2));
shading interp
c=colorbar;
caxis([0 0.4])
axis([5 80 -350 0])
colormap(cchl);
set(gca, 'Xdir', 'reverse')
1 Kommentar
Mathieu NOE
am 10 Feb. 2025
hello
pls share some data along , it's much more efficient to get some help from the community :)
Akzeptierte Antwort
Karan Singh
am 12 Feb. 2025
There are some things that needs to be taken care of-
- "pcolor" is for 2D plots and cannot directly interact with 3D axes. Use "surf" or "slice" for 3D visualization. https://in.mathworks.com/help/matlab/ref/surf.html?requestedDomain= https://in.mathworks.com/help/matlab/ref/slice.html?s_tid=doc_ta
- The axes (Xlon, Ylat, Zdep) must share the same coordinate system as your temperature section.
As Mathieu correctly stated we need some data to continue, I have written down a code considering some dummy data for the same.
% Dummy data for 3D map
[Xlon, Ylat] = meshgrid(32:0.1:37, 26:0.1:30); % Longitude and latitude grid
Zdep = -2800 + 5600 * rand(size(Xlon)); % Random depth values between -2800 and 2800
% Dummy data for temperature section
xl = 1:50; % Index for the section
Xgrid2 = linspace(32, 37, 50); % Longitude values for the section
Zgrid = linspace(-350, 0, 20); % Depth values for the section
chl = 0.4 * rand(20, 50); % Random temperature values (20 depths x 50 longitudes)
% Define the latitude for the section
Ylat_section_value = 28.5; % Fixed latitude for the section
% Plot the 3D map
figure;
surf(Xlon, Ylat, Zdep, 'EdgeColor', 'none');
shading interp;
colormap(jet); % Use a colormap for the map
Zlimit = [-2800 2800];
caxis(Zlimit);
view(20, 70);
axis([32 37 26 30 -2800 2800]);
xlabel('Longitude [\circE]', 'fontsize', 14);
ylabel('Latitude [\circN]', 'fontsize', 14);
zlabel('Depth [m]', 'fontsize', 14);
colorbar;
hold on;
% Prepare the temperature section for 3D
[Xlon_section, Zdep_section] = meshgrid(Xgrid2, Zgrid); % Create grid for section
Ylat_section = repmat(Ylat_section_value, size(Xlon_section)); % Repeat latitude for section
% Plot the temperature section in 3D
surf(Xlon_section, Ylat_section, Zdep_section, chl, 'EdgeColor', 'none');
shading interp;
colormap(parula); % Use a different colormap for the section
caxis([0 0.4]); % Adjust color limits for temperature
colorbar;
% Adjust depth direction
set(gca, 'Zdir', 'reverse');
% Add transparency to the temperature section (optional)
alpha(0.7);
% Final adjustments
view(20, 70);
axis([32 37 26 30 -2800 2800]);
title('3D Map with Temperature Section', 'fontsize', 16);
Karan
0 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Orange finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!