Shifting a plot in the horizontal direction

90 views (last 30 days)
Hello,
I would like to shift my plot horizontaly but here my problems :
First my code :
if true
% %plot of 3 different channels (in the same figure)
figure(3)
%subplot(121)
plot(ERP.bindata(7,:,1),'k');
hold on;
plot(ERP.bindata(10,:,1),'r');
hold on;
plot(ERP.bindata(17,:,1),'b');
title('Fz Cz Pz channel waveforms')
set(gca,'YDir','Reverse') %reversing the Y axis in order to have the negatives values above and the positives values below
axis ([-200,800,-12,12]) %setting of plot's boundary
xlabel('time (ms)')
ylabel('voltage (µV)')
end
I've glanced this subject below, but it didn't help because it gives tipes for plot(x,y) and my isn't configured like this. shift a plot in the vertical direction?
I've tried this :
if true
% plot(ERP.bindata(7,:,1) -200,'k');
plot(-200,ERP.bindata(7,:,1),'k');
end
But when I do this, my I have no plot on the appearing figure. I think it's because the data I've extracted are only ordinate like data but I have approximatively 1000 points for the abscissa.

Accepted Answer

Jos (10584)
Jos (10584) on 8 Feb 2016
The command plot(Y) plots the values of Y against their indices as x values. In general, however, it is a good idea to specify the x values directly. In doing so, you are much more in control. As an example:
Y = cumsum(rand(10,2)) % arbitrary data
x = 1:size(Y,1) ; % specify x values
plot(x, Y(:,1), 'bo-') ; hold on
plot(x+2, Y(:,2), 'rs-') ; hold off
xlim([0 15]) % set plot limits
  1 Comment
Omer Yenil
Omer Yenil on 8 Feb 2016
After writting your codes, I had another issue about matrix (I didn't define my X size very well) but now it's okay, I have my curve begining at -200 instead of 0 like I wanted.
Thank you.

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D 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!