Flipping the axis starting value of a plot in matlab

10 ビュー (過去 30 日間)
Yanjika O
Yanjika O 2020 年 7 月 31 日
コメント済み: Yanjika O 2020 年 8 月 3 日
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
  1 件のコメント
Yanjika O
Yanjika O 2020 年 8 月 3 日
Oh, nice. This is exactly what i was trying to say. Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by