Plotting cartesian coordinates of animal paths
18 views (last 30 days)
Show older comments
Hello everyone,
I have spent the last few weeks ironing out the complicated parts of a (once dead) data set. All of the difficult mathematics are done and I have a beautiful code that spits out a perfect, time-stamped matrix. I want to plot these x and y coordiantes (the 3rd and 4th columns of my data); however, I have gone through the different posts on here re: plotting cartesian points and have not yet found a working solution.
My data looks something like this:
0 0 0 0
1 0.20 -3.99640 -0.265350
2 0.40 -1.10210 0.462070
3 0.60 -2.43890 0.371960
4 0.80 -0.2320 -0.553330
5 1 0.0904320 -1.32830
6 1.20 -14.1930 0.138860
Column1 is an index
Column2 is a timestamp
Column3 is the animal's position along the x-axis (x coordinate)
Column4 is the animal's position along the y-axis (y coordinate)
Other solutions posted on here seem to consider the X and Y coordinates separately, rather than as two defining features of a single point in space. I suppose in that way, my goal is plot the index value and it's affiliated x and y values (though this may just be semantics).
At the end of the day, my goal is take several hundred iterations of this type of path data and generate a heat map to compare path features between samples.
Many thanks.
0 Comments
Accepted Answer
Image Analyst
on 13 Oct 2015
Why can't you just use plot() to plot the x and y coordinates and use text() to put the index number beside the point?
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
D = [0 0 0 0
1 0.20 -3.99640 -0.265350
2 0.40 -1.10210 0.462070
3 0.60 -2.43890 0.371960
4 0.80 -0.2320 -0.553330
5 1 0.0904320 -1.32830
6 1.20 -14.1930 0.138860]
x = D(:, 3);
y = D(:, 4);
plot(x, y, 'bo-', 'LineWidth', 2, 'MarkerSize', 12);
grid on;
title('Animal Positions', 'FontSize', fontSize);
xlabel('X', 'FontSize', fontSize);
ylabel('Y', 'FontSize', fontSize);
% Now plot index numbers along side the markers.
hold on;
for k = 1 : size(D, 1)
string = sprintf(' Time Point %d', k);
text(x(k), y(k), string, 'FontSize', 14, 'Color', 'm');
end
% Draw in the X and Y axis
line(xlim, [0,0], 'Color', 'k', 'LineWidth', 3);
line([0,0], ylim, 'Color', 'k', 'LineWidth', 3);
4 Comments
Litalo
on 3 Sep 2020
Hi :-)
do you have completed method you can share? i need to do this also...
Best,
Lital
More Answers (0)
See Also
Categories
Find more on Data Distribution Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!