Changing plots origin

How can I change origin when creating a 2D plot. I need it to be at [pi,0].

x = 0:0.1:2*pi;
y = sin(x);
v = [x(: ) y(:)];
for theta = 0:0.05:2*pi
  R = [cos(theta) sin(theta); -sin(theta) cos(theta)];
  vr = v*R;
  x = vr(:,1);
  y = vr(:,2);
  plot(x, y);
  hold on; %boje
  axis([-0.5 6.5 -4 4]);


Does plot(x + pi, y); do what you want?

1 Like

It’s a little unclear what you are trying to do. If you are trying to move the plot around on the XY-plane then just add offsets to the X-data and Y-data as @siko1056 suggested.

If you are trying to move the lines and tick marks of the axis then you want to adjust the xaxislocation and yaxislocation properties of the current axes object.

For the latter, I ran your original code and the added

axis tight
set (gca, 'xaxislocation', 'origin')
set (gca, 'yaxislocation', 'origin')

Results are shown below:

You can change tickmarks and labels too if you are trying for more natural units for a trigonometric problem which might be [0, pi/2, pi, 3*pi/2, 2*pi].


It does thanks!

Thanks for your help too!