How to change axis limits and step pitch of a MatLab shape?

I have a simple schedule yagainst x.

y = [6,-1.3,-8,-11.7,-11,-6,1.3,8,11.7,11,6,-1.3];
x = 0:0.3:3.3;
plot (x,y)

As a result, the x axis of the figure is in the range from 0 to 3.5 with a scale of 0.5. I used XLimit = [0 3.3]to limit the axis, but it doesn't seem to work.

I want to make the x axis range from 0 to 3.3 in increments of 0.3.

+4
source share
2 answers
axis tight % removes the empty space after 3.3
set(gca,'XTick',0:0.3:3.3) % sets the x axis ticks
+5
source

With XLimit = [0 3.3]you just define a vector with a name XLimit. To use this vector as a horizontal limit, you must use xlim:

xlim(XLimit)
% or directly:
xlim([0, 3.3])

xlim . ylim.

, x, , , :

axis tight

, , y.

, AVK, set 'XTick' 0:0.3:3.3:

set(gca,'XTick',0:0.3:3.3)

gca - .

+3

Source: https://habr.com/ru/post/1657120/


All Articles