how to make 2D graph with 3 data set
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
sensation
el 23 de Jun. de 2017
Comentada: Star Strider
el 27 de Jun. de 2017
hi, I was wondering if someone can give me a hint how to create a multiple line graph where each line will be associated to certain Z line for example. I have data like attached where x is first column and so on.
So I want to have a 2D graph with x and y scatter points, and then through these points sometimes will pass a line that reflect a z column. Z column ranges between 16 and 145 m. It would be great if I can have lines at 15 35 55 75 95 115 135 155 m for example. Thanks a lot!
I have a scatter with but cant figure it out how i can plot lines at these intervals corresponding to Z values:
x=all(:,1);
y=all(:,2);
z=all(:,3);
pointsize = 10;
scatter(x, y, pointsize, z);
0 comentarios
Respuesta aceptada
Star Strider
el 23 de Jun. de 2017
See if this does what you want.
The Code —
D = load('sensation scatter_test.txt');
[Du,~,ic] = unique(D(:,2)); % Unique Values — Second Column
xc = accumarray(ic, D(:,1), [], @(x) {cat(3,x)}); % Accumulate ‘x’ In 3D Matrix
yc = accumarray(ic, D(:,2), [], @(x) {cat(3,x)}); % Accumulate ‘y’ In 3D Matrix
zc = accumarray(ic, D(:,3), [], @(x) {cat(3,x)}); % Accumulate ‘z’ In 3D Matrix
figure(1)
for k1 = 1:size(xc,1)
plot3(xc{k1}, yc{k1}, zc{k1}) % Plot Each ‘(x,y,z)’ Separately On Same Axes
hold on
lgnd{k1} = sprintf('%6.2f',yc{k1}(1)); % Create Legend Entries
end
hold off
grid on
view([0 0]) % Rotate 3D Plot To 2D
legend(lgnd{:}, 'Location','SE')
The Plot —
6 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!