Flipping the axis starting value of a plot in matlab
1 view (last 30 days)
Show older comments
Hi,
Here is the code that I wrote for plotting some points and writing it to a video. When I want to match the plot with the original video the origin value of y axis of my created plot is reversed. How can I change to y axis origin?
clear all;clc;
clear X; clear Y;
filename='test';
Ezfilename=strcat(filename,'_LocationOutput.csv');
col='I':'J';
repeats=1;
X=xlsread(Ezfilename,regexprep(Ezfilename,'.csv',''),strcat(col(1),':',col(1)));
Y=xlsread(Ezfilename,regexprep(Ezfilename,'.csv',''),strcat(col(2),':',col(2)));
for i=1:repeats
writerObj=VideoWriter(strcat('Conditioning',num2str(i),'.mp4'),'MPEG-4');
writerObj.FrameRate=30;
open(writerObj);
figure(i);
dscatter(X,Y);
colorbar;
hold on
plot1=scatter(X(1),Y(1),100,'r+');
grid on;
box on;
xlabel('[px]')
ylabel('[px]')
xlim([0 1280]);
ylim([0 720]);
title('Animal movement during conditioning');
for j=1:length(X)
plot1.XData=X(j);
plot1.YData=Y(j);
%addpoints(curve(X(j),Y(j)));
drawnow
F(j)=getframe(gcf);
writeVideo(writerObj,F(j));
end
close(writerObj);
close all
end
Please give your recommendations,
Thank you
0 Comments
Accepted Answer
J. Alex Lee
on 31 Jul 2020
Does this do what you want
figure(i);
dscatter(X,Y);
colorbar;
hold on
set(gca,'YDir','reverse') % <- added this line
More Answers (0)
See Also
Categories
Find more on Annotations 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!