我的绘图遇到了麻烦,因为当我处理它时,轴标签似乎显示在 Jupyter Notebooks 中。
但是,当我将文件导出到 .py 文件并在终端中运行它时,给出的图表没有轴标签。
fig = plt.figure(figsize = (15,5))
ax = fig.add_axes([0,0,1,1])
ax.set_title('Oil vs Banks Mean Return')
ax.set_xlabel('Date')
ax.set_ylabel('Price')
ax.plot(all_returns['Mean'], label = 'Banks Mean', color = 'green')
ax.plot(all_returns['Oil'], label = 'Oil', color = 'black')
ax.plot(movavg['Mean'], label = 'Mean MA', color = 'blue')
ax.plot(movavg['Oil'], label = 'OIL MA', color = 'red')
ax.legend()
plt.tight_layout();
In Jupyter Notebooks it shows the axes and labels eg. Year etc.:
However, when I export it, they are gone: