How to view the index of a line (or set of connected lines) in a plot?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Suppose, I am plotting the following trajectory (connected lines) data:
% first trajectory data
track(1).x = [1 1 1 2 4 5];
track(1).y = [20 21 23 24 25 25];
% second trajectory data
track(2).x = [34 35 36 37];
track(2).y = [90 92 94 96];
hold on;
%plotting the trajectory
for i=1:length(track)
plot(track(i).x,track(i).y)
end
hold off;
In the above code it would be easy to identify the index of the trajectory (here 1 and 2) looking at the plot.
But, when the length of the variable "track" increases i.e, when there are more number of trajectories, I find it difficult to indetify the index of a random trajectory in the plot.
One possible way might be to create labels and display it. But then, if too may trajectories are there, it would be chaos and labels might not be visible.
My question is based on this: Is there any way to visualize the index of the trajectories in a plot, just like when we place the "data-tip" tool in the plot it would show us the values of the line (ie,co-ordinates), for analysis purpose ?
0 Kommentare
Akzeptierte Antwort
KSSV
am 3 Jul. 2019
How about this approach? Click at the point you want to know the label.
% first trajectory data
track(1).x = [1 1 1 2 4 5];
track(1).y = [20 21 23 24 25 25];
track(1).label = 1*ones(1,6) ;
% second trajectory data
track(2).x = [34 35 36 37];
track(2).y = [90 92 94 96];
track(2).label = 2*ones(1,4) ;
hold on;
%plotting the trajectory
for i=1:length(track)
plot(track(i).x,track(i).y)
end
hold off;
%% Pick a point
[ptx,pty] = getpts() ;
x = [track(:).x]' ;
y = [track(:).y]' ;
l = [track(:).label]';
%
F = scatteredInterpolant(x,y,l) ;
li = round(F(ptx,pty)) ;
text(ptx,pty,num2str(li))
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Point Cloud Processing 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!