我想修正拥挤的日期是轴,并且在图形至少更新一次之后立即出现一条线,我在python中不是很好。我该如何解决我的问题?
import datetime as dt
import pandas_datareader as web
import matplotlib.pyplot as plt
import csv
import matplotlib.animation as animation
start = dt.datetime(2019, 4, 1)
fig = plt.figure(1)
ax1 = fig.add_subplot(1, 1, 1)
b = []
c = []
def animate(i):
a = web.get_data_yahoo('AAPL', start, dt.datetime.now())
f = open(r'C:\Users\HOME-PC\Desktop\python\people1.csv', 'w')
a.to_csv(f)
f.close()
with open('people1.csv', 'r') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
b.append(row['Date'])
c.append(round(float(row['Close'])))
ax1.clear()
ax1.plot(b, c)
plt.title(" Stock Market Price Of ")
plt.ylabel("Price in USD")
plt.xlabel("Year")
ani = animation.FuncAnimation(fig, animate, interval=1000)
plt.show()
至少更新一次之前的输出:
至少更新一次后输出: