0
私は以下のスクリプトを書いて、GBP-EUR為替レートを取得し、matplotlibを使って動的にプロットします。スクリプトは無限に実行され、グラフを更新しますが、ラベルと軸の制限は表示されません。この?matplotlib.animateのラベルと軸の制限を設定するには?
`#!/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()`