如何在动画图上设置刻度位置?

在下面的代码中,绘图不使用我用 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()
lhy12565 回答:如何在动画图上设置刻度位置?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2172.html

大家都在问