我有这段代码:
这是另一个代码的示例,但问题相同:
在图的底部,可以看到图例被裁剪了。在我正在处理的另一个代码的另一个图中,当我使用plt.savefig('Test')保存图时,甚至ylabel也会被裁剪。我该如何解决这个问题?
import pandas as pd
from pandas import datetime
from pandas import DataFrame as df
import matplotlib
from pandas_datareader import data as web
import matplotlib.pyplot as plt
import datetime
start = datetime.date(2016,1,1)
end = datetime.date.today()
stock = 'fb'
fig = plt.figure(dpi=1400)
data = web.DataReader(stock, 'yahoo', start, end)
fig, ax = plt.subplots(dpi=720)
data['vol_pct'] = data['Volume'].pct_change()
data.plot(y='vol_pct', ax = plt.gca(), title = 'this is the title \n second line')
ax.set(xlabel="Date")
ax.legend(loc='upper center', bbox_to_anchor=(0.32, -0.22), shadow=True, ncol=2)
plt.savefig('Test')
这是另一个代码的示例,但问题相同:
![enter image description here](https://istack.dev59.com/eUOs0.webp)