我是一名初学者python编码器,目前在使“ RSI”子图的宽度小于上表时遇到很多麻烦。而且我也无法将x轴设置为excel文件第一列中的指定时间。
这是我的代码:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import datetime as dt
stock_data=pd.read_excel('/Users/ariannadambrosio/Downloads/Assignment2-data.xlsx',parse_dates = True,index_col = 0)
closing_price=stock_data['Close']
rsi=np.array(stock_data['RSI'])
sma=stock_data['sma']
x = stock_data.index.to_pydatetime()
fig, axs = plt.subplots(2, 1,
gridspec_kw={'hspace': 0},)
(ax1, ax2) = axs
fig.suptitle('Analysis Of Stock')
ax1.plot(closing_price)
ax1.plot(figsize=(15,15))
ax2.plot(rsi)
ax2.legend('RSI')
ax2.plot(figsize=(3,15))
plt.figure
这是我当前的输出: