3d plotting of Lat, Long and depth

Hi,
I am trying to create a 3D plot - please see attached image.
However, i need to flip the scale so that the depth (km) increases downwards and I need to plot it in a 1:1 aspect ratio as all 3 axis are not equal in reality... Does anyone know how to do this?
Eventually i will need to plot elipsoid errors around these data points - if anyone has any experience with this, then I would be extremely grateful if you could share how you did it!
Many thanks!!

 Risposta accettata

Cris LaPierre
Cris LaPierre il 8 Feb 2019
Modificato: Cris LaPierre il 8 Feb 2019
Try this:
axis equal
ax = gca;
ax.ZDir = 'reverse';

6 Commenti

Hi Cris, thank you for getting back to me!
I couldn't get the 'axis equal' code to't work.. my Lat and Long data are in degrees and my depth is in km. 1 deg ~ 111km. Do you know if there's a way to successfully plot both of these scales together?
Please see my data/ code attached
Many thanks!!
%% Data
Lat=[40.758853 40.763073 40.761671 40.760265 40.763082 40.758853 40.758853 40.756036 40.761671 40.761677 40.763085 40.763082 40.760265 40.758853 40.753203];
Long=[30.396377 30.39452 30.400074 30.401927 30.405623 30.396377 30.396377 30.392681 30.400074 30.407476 30.409325 30.405623 30.401927 30.396377 30.374183];
Depth=[10.623437 11.313867 11.136328 10.248633 10.84043 10.623437 12.201562 10.347266 11.373047 10.426172 10.288086 10.011914 10.011914 9.992187 11.807031];
%% Script
figure (1)
scatter3(Long(:), Lat(:), Depth(:),'o','MarkerEdgeColor','k', 'MarkerFaceColor',[0 .75 .75]);
%axis equal
ax = gca;
ax.ZDir = 'reverse';
xlabel('Long (deg)')
ylabel('Lat (deg)')
zlabel('Depth (km)')
%grid on
Cris LaPierre
Cris LaPierre il 9 Feb 2019
Modificato: Cris LaPierre il 14 Feb 2019
Let's be clear: axis equal is working just fine, it's just not creating the result you want. As the name implies, it makes the step size the same on every axis, resulting in a visually scaled plot. It knows nothing about units.
Since you know the relationship between the two units (1deg = 111km), you can plot with everything being the same units (I'd convert km to degree). I would then update the Z tick labels to be in degrees (current value*111).
Just note, manually updating your labels means they won't automatically update if additional data is added or if the figure is resized. Make sure you have your final image before changing them.
%% Data
Lat=[40.758853 40.763073 40.761671 40.760265 40.763082 40.758853 40.758853 40.756036 40.761671 40.761677 40.763085 40.763082 40.760265 40.758853 40.753203];
Long=[30.396377 30.39452 30.400074 30.401927 30.405623 30.396377 30.396377 30.392681 30.400074 30.407476 30.409325 30.405623 30.401927 30.396377 30.374183];
Depth=[10.623437 11.313867 11.136328 10.248633 10.84043 10.623437 12.201562 10.347266 11.373047 10.426172 10.288086 10.011914 10.011914 9.992187 11.807031];
%% Script
scale = 111; % km/deg
scatter3(Long(:), Lat(:), Depth(:)/scale,'MarkerEdgeColor','k', 'MarkerFaceColor',[0 .75 .75]);
axis equal
ax = gca;
ax.ZDir = 'reverse';
zVal = str2double(ax.ZTickLabel)*scale;
ax.ZTickLabel = num2str(zVal);
xlabel('Long (deg)')
ylabel('Lat (deg)')
zlabel('Depth (km)')
%grid on
Cris LaPierre
Cris LaPierre il 9 Feb 2019
Modificato: Cris LaPierre il 9 Feb 2019
Actually, I think it would be better to set the tick labels this way:
zval = [9.5:.5:12.5]';
ax.ZTick = zval/scale;
ax.ZTickLabel = num2str(zval);
P_L
P_L il 14 Feb 2019
Hi Chris, I'm so sorry for the delayed response. Your script suggestions were very helpful!! Please find attched of the result with your suggestions. I have tried rotating the image and moving it but for some reason, the depth axis does show. Do you know why it would do this? please see attcahed.
Many Many Thanks
:)
Could you share your code? Did you scale your Z values correctly? What version of MATLAB are you using?
It works as expected for me.
3D_LatLongDep.png
P_L
P_L il 14 Feb 2019
Hi Chris,
Problem solved!! Thank you so much !!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Geology in Centro assistenza e File Exchange

Richiesto:

P_L
il 8 Feb 2019

Modificato:

P_L
il 28 Feb 2019

Community Treasure Hunt

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

Start Hunting!

Translated by