【发布时间】:2016-05-18 20:51:51
【问题描述】:
下面的代码应该给我单独的图表,每个图表都有一行数据,但由于某种原因,第一个图显示了“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()
【问题讨论】:
标签: python pandas matplotlib dataframe