Flipping the axis starting value of a plot in matlab

2 次查看(过去 30 天)
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

采纳的回答

J. Alex Lee
J. Alex Lee 2020-7-31
Does this do what you want
figure(i);
dscatter(X,Y);
colorbar;
hold on
set(gca,'YDir','reverse') % <- added this line

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by