I created this function
def plotPrediction(testY, predictY, testYIndex, predictIndex, fileName):
# Use datetime for creating date objects for plotting
# Plot the actual values
plt.plot(testY.index, testY[testYIndex], 'b-', label = 'actual');
# Plot the predicted values
plt.plot(testY.index, predictY[:, predictIndex] , 'ro', label = 'prediction')
plt.xticks(rotation = '60');
plt.legend()
# Graph labels
plt.xlabel('Date'); plt.ylabel(testYIndex); plt.title('Actual and Predicted DepositCount');
plt.savefig(fileName+testYIndex+'.png')
Then I call this function by doing:
plotPrediction(testY, predictY, 'DepositCount',0, 'forestpredict');
plotPrediction(testY, predictY, 'DepositAmount',1, 'forestpredict');
plotPrediction(testY, predictY, 'WithdrawCount',2, 'forestpredict');
plotPrediction(testY, predictY, 'WithdrawAmount',3, 'forestpredict');
My idea was that as my predictY has multiple outputs, I would like to plot each output in different png file. However, the output files show the same image (other than first one). I am guessing that I need to clean the canvas or maybe there are some functions to tell matplotlib to start a new chart?