Struggling to lay 2D points over a 3D scatter plot

5 visualizzazioni (ultimi 30 giorni)
Hello there!
I have a plot that shows tectonic plates subducting at a specific location (once tectonic plates go below the surface, they are called slabs. Referred to as slabs from here forward). I have my three slabs plotted using scatter3 and colored by depth as shown. What I want to add, though, are volcanoes at the surface of this plot.
First -- my code for the plot itself.
dat1 = load('kur_slab2_dep_02.24.18.xyz'); % Japan trench data
dat2 = load('ryu_slab2_dep_02.26.18.xyz'); % Ryukyu Nankai trench data
dat3 = load('izu_slab2_dep_02.24.18.xyz'); % Izu Bonin trench data
datf = [dat1; dat2; dat3]; % slabs put together
x1 = datf(:,1); % creating all xs
y1 = datf(:,2); % creating all ys
z1 = datf(:,3); % creating all zs
xv1 = linspace(min(x1), max(x1), 400); % creating linearly spaced points between min and max of all x
yv1 = linspace(min(y1), max(y1), 400); % creating linearly spaced points between min and max of all x
[X1,Y1] = meshgrid(xv1, yv1); % taking those linearly spaced points and making it into a grid
Z1 = griddata(x1,y1,z1,X1,Y1); % assigning a variable to the grid so it can be plotted
c = datf(:,3); % starting of colorbar info
figure(2)
scatter3(datf(:,1), datf(:,2), datf(:,3), 3, c); % plotting the information
title('The Boso Triple Junction subducting slabs');
xlabel(['Longitude (' char(176) ')']);
ylabel(['Latitude (' char(176) ')']);
zlabel('Slab Depth (km)');
col = colorbar;
set(get(col,'label'),'string','Depth in km');
grid on
This code creates this figure:
Now, I have volcanoes in the area in a file that looks something like:
Longitude Latitude Depth
125 45 0
137 43 0
140 39 0 etc.
I would love to have the volcanoes plotted as stars at the 'surface' (where depth of the slabs is equal to zero) of this plot, but I have been having trouble getting MATLAB to work with me (mostly because of my trouble with scatter3, I think, and figuring out how to alter the data format accordingly). Does anyone have any thoughts?
The slab data is too large to attach, but if anyone needs it or is curious, it's free data available at (https://www.sciencebase.gov/catalog/item/5aa1b00ee4b0b1c392e86467/). I use the Izu-bonin, Japan-Kuril-Kamchatka, and Ryukyu-Nankai depth xyz files (full name shown in code).
volcano data:
volclist.txt
Thank you for your time!!

Risposta accettata

Ive J
Ive J il 4 Apr 2023
Spostato: the cyclist il 4 Apr 2023
what about hold on?
hold on
voc = [125, 45, 0; 140, 39, 0];
scatter3(voc(:, 1), voc(:, 2), voc(:, 3), "*") % or plot3
  1 Commento
Jane Halfhill
Jane Halfhill il 4 Apr 2023
Spostato: the cyclist il 4 Apr 2023
Hi there!
That totally worked! The code looks a little messy because I actually have about 200 volcanoes to plot, but I'm so happy that it plots and I'm really the only one who will ever see how it looks. I super appreciate your time and response to my question!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by