# 3D plot of Latitude, Longitude and Depth while the colour of the points represent earthquake magnitude

15 views (last 30 days)
Michelle Pearce on 2 Aug 2022
Commented: Michelle Pearce on 2 Aug 2022
I have been able to plot the points using scatter3 but I am struggling on making the colour of the points represent the earthquake magnitude. I am using an excel file with the following columns 'lat', 'long', 'depth' and 'mag'. I have 2461 earthquakes to plot therefore it is a 2461x4 table. Below is the code I have used to plot the points and I have attached a screenshot of what I get when I run the code. I have also attached a screenshot called "Desired_Result" which is what I would like the final product to look like. I do not have much MATLAB experience so any help you can provide would be greatly appreciated! Thank you!
%Defining Variables
lat = table2array(eqs(:,1));
long = table2array(eqs(:,2));
Depth = table2array(eqs(:,3));
Mag = table2array(eqs(:,4));
%plot
scatter3(long,lat,Depth)
%reversing the z axis
set(gca,'ZDir','reverse')
%Labels
ylabel('Latitude')
xlabel('Longitude')
zlabel('Depth(km)')
Title('Himalaya Earthquakes')

KSSV on 2 Aug 2022
scatter3(long,lat,Depth,[],Depth,'filled')
Michelle Pearce on 2 Aug 2022
Thank you! That worked! I just put scatter3(long,lat,Depth,[],Mag,'filled') instead. Thank you again!

### Categories

Find more on Seismology in Help Center and File Exchange

R2021b

### Community Treasure Hunt

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

Start Hunting!