以下代码应该为我提供单独的图表,每个图表都有一行数据,但由于某种原因,第一个图显示了' GrowthVsValue'然后第二个图显示了' GrowthVsValue'再次排队并添加“LargeVsSmall”'线。但我希望他们在不同的数字中独立存在。我需要添加/做什么才能使其工作?
from matplotlib.backends.backend_pdf import PdfPages
pp = PdfPages('Relative Strength.pdf')
Output = pd.DataFrame({
'GrowthVsValueDIFF': 1 + (df_ch['IVV'] - df_ch['IVE']),
'LargeVsSmallDIFF': 1 + (df_ch['IVV'] - df_ch['IJR']),
}, index = df_ch.index)
Output['GrowthVsValue'] = 100
Output.loc[1:, 'GrowthVsValue'] = Output.GrowthVsValueDIFF[1:].cumprod() * 100
Output.GrowthVsValue.plot.line(legend=None)
Output.GrowthVsValue_L = plt.title('Growth v. Value RS')
plt.savefig(pp, format='pdf')
Output['LargeVsSmall'] = 100
Output.loc[1:, 'LargeVsSmall'] = Output.LargeVsSmallDIFF[1:].cumprod() * 100
Output.LargeVsSmall.plot.line(legend=None)
Output.LargeVsSmall_L = plt.title('Large v. Small RS')
plt.savefig(pp, format='pdf')
pp.close()
答案 0 :(得分:1)
在第一个plt.close()
plt.savefig()