Reputation: 155
I am trying to plot some 2D lines with Matlab. I am trying to get the plot to show the intersection point between the x-axis and y-axis in the middle of the plot so I can see how the lines proceed in the negative x-range and y-range.
I've tried the axis
command. But this will just scale the XMIN XMAX YMIN YMAX
... etc in the plot
Thanks!
here is my code for plotting:
plot(AOA,y,'g-o')
hold on
pl = plot(AOA,CLspanloading,'c-o');
set(pl,'linewidth',2);
xlabel('Alpha')
ylabel('CL')
title('Lift Polar')
axis([-5 8 -1 1.5])
% legend('LowerCL','UpperCL','-Spanloading','Location','SouthEast')
legend('F27 Paper','Spanloading','Location','SouthEast')
Upvotes: 0
Views: 1151
Reputation: 3674
You can also use xlim
and ylim
to adjust the scale of the current axes:
xlim([XMIN XMAX]);
ylim([YMIN YMAX]);
And to center the axis on the origin in the plot, make sure the magnitudes of XMIN/XMAX are the same, as well as the magnitudes of YMIN/YMAX:
xlim([-XMAX XMAX]);
ylim([-YMAX YMAX]);
Upvotes: 1
Reputation: 3177
The axis
command must be used wisely. The XMIN
and the XMAX
should have the same value and the same goes for YMIN
ad YMAX
. The only thing that must be changed, is the sign: indeed, XMIN=-XMAX
and YMIN=-YMAX
(where, of course XMAX>0
and YMAX>0
).
By running this simple code
plot(1:50,1:50,'g-o')
xlabel('Alpha')
ylabel('CL')
title('Lift Polar')
axis([-8 8 -8 8]); grid on;
i get
Now, sure this line doesn't mean a thing...it's just for demo purposes. But as you can see the origin is exactly in the middle of the plot.
Upvotes: 2