在下面的代码中,绘图不使用我用 MultipleLocator 定义的刻度。我不知道为什么。 我尝试在 animate 函数中设置刻度位置,但没有用。
请!有人可以告诉我如何解决这个问题
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator
import matplotlib.animation as animation
fig = plt.figure()
ax = fig.add_subplot(111)
ax.xaxis.set_major_locator(MultipleLocator(1))
ax.xaxis.set_major_locator(MultipleLocator(1))
def animate(i):
f = open('data2.csv','r').read()
lines = f.split('\n')
x,y = [],[]
for line in lines:
if len(line) > 1:
a,b = line.split(';')
x.append(float(a))
y.append(float(b))
ax.clear()
ax.plot(x,y)
animation = animation.FuncAnimation(fig,animate,interval = 1000)
plt.show()