为什么视图不会随着 FuncAnimation 绘制的新数据而改变?
Why the view doesn't change with the new data that plotted by FuncAnimation?
我正在绘制一些数据,但没有看到。如果缩小,您会发现数据绘制在图的另一侧,并且视图不会...自动更改为能够看到数据。有人可以帮帮我吗?
from matplotlib import pyplot as plt
from matplotlib.animation import FuncAnimation
fig = plt.figure()
ax = fig.add_subplot()
line, = ax.plot([],[])
x = []
y = []
def animate(i):
x.append(i)
y.append((-1)**i)
line.set_data(x, y)
return line,
anim = FuncAnimation(fig, animate, frames=200, interval=100, blit=True)
plt.show()
按照, you need to call the axes relim
and autoscale_view
方法。
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.animation import FuncAnimation
fig = plt.figure()
ax = fig.add_subplot()
line, = ax.plot([],[])
x = []
y = []
def animate(i):
x.append(i)
y.append((-1)**i)
line.set_data(x, y)
ax.relim()
ax.autoscale_view()
return line,
anim = FuncAnimation(fig, animate,
frames=200, interval=100, blit=True)
plt.show()
我正在绘制一些数据,但没有看到。如果缩小,您会发现数据绘制在图的另一侧,并且视图不会...自动更改为能够看到数据。有人可以帮帮我吗?
from matplotlib import pyplot as plt
from matplotlib.animation import FuncAnimation
fig = plt.figure()
ax = fig.add_subplot()
line, = ax.plot([],[])
x = []
y = []
def animate(i):
x.append(i)
y.append((-1)**i)
line.set_data(x, y)
return line,
anim = FuncAnimation(fig, animate, frames=200, interval=100, blit=True)
plt.show()
按照, you need to call the axes relim
and autoscale_view
方法。
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.animation import FuncAnimation
fig = plt.figure()
ax = fig.add_subplot()
line, = ax.plot([],[])
x = []
y = []
def animate(i):
x.append(i)
y.append((-1)**i)
line.set_data(x, y)
ax.relim()
ax.autoscale_view()
return line,
anim = FuncAnimation(fig, animate,
frames=200, interval=100, blit=True)
plt.show()