def percent_change_as_time_plot(adjusted_df):
"""
This function visualizes the percentage change data as a time series plot.
:param adjusted_df: Pandas DataFrame with columns: Date, Adjusted Close, and Percentage Change.
"""
pct_change_list = adjusted_df['Percentage Change'].tolist()
date_list = adjusted_df.index.values
fig, ax = plt.subplots()
ax.plot(date_list, pct_change_list)
#ax.plot(date_list, adjusted_df["Adjusted Close"])
plt.xlabel("Years")
plt.ylabel("Percentage change from last week")
plt.title("Percentage change in S&P 500 weekly data from 2009 to 2016")
ax.xaxis.set_minor_locator(MonthLocator())
ax.yaxis.set_minor_locator(MultipleLocator(1))
ax.fmt_xdata = DateFormatter('%Y-%m-%d')
ax.autoscale_view()
fig.autofmt_xdate()
plt.show()
markov_stock_analysis v2-2.py 文件源码
python
阅读 29
收藏 0
点赞 0
评论 0
评论列表
文章目录