def plotAccuracyGraph(X, Y, Xlabel='Variable', Ylabel='Accuracy', graphTitle="Test Accuracy Graph", filename="graph.pdf"):
""" Plots and saves accuracy graphs """
try:
timestamp = int(time.time())
fig = P.figure(figsize=(8,5))
# Set the graph's title
P.title(graphTitle, fontname='monospace')
# Set the axes labels
P.xlabel(Xlabel, fontsize=12, fontname='monospace')
P.ylabel(Ylabel, fontsize=12, fontname='monospace')
# Add horizontal and vertical lines to the graph
P.grid(color='DarkGray', linestyle='--', linewidth=0.1, axis='both')
# Add the data to the graph
P.plot(X, Y, 'r-*', linewidth=1.0)
# Save figure
prettyPrint("Saving figure to ./%s" % filename)#(graphTitle.replace(" ","_"), timestamp))
P.tight_layout()
fig.savefig("./%s" % filename)#(graphTitle.replace(" ", "_"), timestamp))
except Exception as e:
prettyPrint("Error encountered in \"plotAccuracyGraph\": %s" % e, "error")
return False
return True
评论列表
文章目录