python - 如何在动画图上设置刻度位置?
问题描述
在下面的代码中,该图不使用我用 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()
解决方案
推荐阅读
- javascript - 剃刀页面javascript只执行一次c#
- kubernetes - Prometheus/Grafana-如何为所有 pod 生成数据点?
- click - 我如何检测鼠标输入,单击。在印刷文本上?
- reactjs - Django 抛出 {"non_field_errors":["Invalid data. Expected a dictionary, but got tuple."]} React JS
- python - 无法同步 Djstripe 中已存在的计划
- ios - 使用AttributedString单击href时是否可以使UILable可单击
- c# - 如何通过在 VBA 项目中导入自定义 DLL 来修复运行时错误 430
- string - 连接访问后,字符串不能连接在一起
- asp.net-mvc - 使用 ASP.NET MVC 从 URL 中删除主目录
- c++ - QPolarChart 的反向轴