# How do you make a fixed schedule at matplotlib?

• There's a dynamic schedule that updates every cadre. When the first point is located, the axis is formed, but when new points are added that are not within the range of these axles, the axis start to grow, distorting the schedule. How to make fixed axles from the start of the schedule? For example, 100 x and 100 y.

Code:

``````import os
import numpy as np
from matplotlib import pyplot as plt
from math import cos, sin
COEFFICIENT = 1.1
START = 0
os.popen("rm -rf " + os.path.dirname(os.path.abspath(file)) + "/dir/*")
vector1 = [2, 6]
fig = plt.figure()
def new_point(x, y):  # Новая точка при повороте
def forward(x, y):
x += 0.1 if x > 0 else - 0.1
y += 0.1 if y > 0 else - 0.1
return x, y
for number in range(720):
print("x = {}, y = {}".format(vector1[0], vector1[1]))
ax.plot(vector1[0], vector1[1], "go")
plt.savefig('./dir/graph{}.png'.format(number))
vector1[0], vector1[1] = forward(*new_point(vector1[0], vector1[1]))
``````

https://i.ibb.co/yyw6TNT/hren2.gif

• Try this:

``````import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np
fig = plt.figure()
ax = plt.axes(xlim=(-50, 50), ylim=(-50, 50))
line, = ax.plot([], [], "go",  lw=2)
def init():
line.set_data([], [])
return line,
xdata, ydata = [], []
def animate(i):
t = 0.1*i
x = t * np.sin(t)
y = t * np.cos(t)
xdata.append(x)
ydata.append(y)

line.set_data(xdata, ydata)
return line,

plt.title('Анимация')
plt.axis('off')
anim = animation.FuncAnimation(
fig,
animate,
init_func=init,
frames=500,
interval=20,
blit=True
)
plt.show()
``````

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2