From 2f74f90c184521991b88270220f8574972e68147 Mon Sep 17 00:00:00 2001 From: Roger Labbe Date: Fri, 9 May 2014 13:55:53 -0700 Subject: [PATCH] Added ability to label the axes. --- bar_plot.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bar_plot.py b/bar_plot.py index 7dc3ac7..fa930a6 100644 --- a/bar_plot.py +++ b/bar_plot.py @@ -7,10 +7,18 @@ Created on Fri May 2 12:21:40 2014 import matplotlib.pyplot as plt import numpy as np -def plot(pos): +def plot(pos, ylim=(0,1)): plt.cla() ax = plt.gca() x = np.arange(len(pos)) ax.bar(x, pos) - plt.ylim([0,1]) - plt.xticks(x+0.5, x) + if ylim: + plt.ylim([0,1]) + plt.xticks(x+0.4, x) + plt.grid() + plt.show() + +if __name__ == "__main__": + p = [0.2245871, 0.06288015, 0.06109133, 0.0581008, 0.09334062, 0.2245871, + 0.06288015, 0.06109133, 0.0581008, 0.09334062]*2 + plot(p) \ No newline at end of file