def summarizePerformance(self, test_data_set):
"""
This function is called at every PERIOD_BTW_SUMMARY_PERFS.
Parameters
-----------
test_data_set
"""
print ("Summary Perf")
observations = test_data_set.observations()
prices = observations[0][100:200]
invest = observations[1][100:200]
steps=np.arange(len(prices))
steps_long=np.arange(len(prices)*10)/10.
#print steps,invest,prices
host = host_subplot(111, axes_class=AA.Axes)
plt.subplots_adjust(right=0.9, left=0.1)
par1 = host.twinx()
host.set_xlabel("Time")
host.set_ylabel("Price")
par1.set_ylabel("Investment")
p1, = host.plot(steps_long, np.repeat(prices,10), lw=3, c = 'b', alpha=0.8, ls='-', label = 'Price')
p2, = par1.plot(steps, invest, marker='o', lw=3, c = 'g', alpha=0.5, ls='-', label = 'Investment')
par1.set_ylim(-0.09, 1.09)
host.axis["left"].label.set_color(p1.get_color())
par1.axis["right"].label.set_color(p2.get_color())
plt.savefig("plot.png")
print ("A plot of the policy obtained has been saved under the name plot.png")
评论列表
文章目录