[英]How to set labels and axes limits for matplotlib.animate?
我正在编写以下脚本以获取GBP-EUR汇率并使用matplotlib对其进行动态绘制,因为该脚本可以无限制地运行广告并更新图形,但是不会出现标签和轴限制,我该怎么做?
`#!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from yahoo_finance import Currency
from time import time
pound = Currency('GBPEUR')
prices = []
times = []
start = time()
n = 0
def animate(i):
pound.refresh()
prices.append(float(pound.get_bid()))
times.append((time() - start))
plt.axis([0,max(times),0,(max(prices)+5)])
plt.xlabel('Time since start, Seconds')
plt.ylabel('Pound-Euro conversion rate')
ax1.clear()
ax1.plot(times,prices)
while True:
pound.refresh()
prices.append(float(pound.get_bid()))
times.append((time() - start))
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
ani = animation.FuncAnimation(fig, animate, interval=1)
plt.show()`
我自己弄清楚了这一点,删除了对ax1.clear()
进行排序的行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.