21 Plots a histogram of a one dimensional list 25 parser = argparse.ArgumentParser(description=
'Plot a histogram')
28 parser.add_argument(
"files", metavar=
"files", nargs=
'+', help=
"files to plot")
31 parser.add_argument(
"-s", type=str, help=
"Name of the simulator", default=
"")
32 parser.add_argument(
"-t", type=str, help=
"Title of the plot", default=
"")
33 parser.add_argument(
"-b", help=
"Number of bins", default=
'auto')
34 parser.add_argument(
"-n", help=
"Normed histogram",
35 default=
False, action=
"store_true")
37 args = parser.parse_args()
40 import matplotlib.pyplot
as plt
43 from dim_labels
import *
48 if bins
is not "auto":
49 plt.hist(data, bins=
int(bins), density=normed, color=
'black',
50 histtype=
"bar", rwidth=0.95)
52 plt.hist(data, density=normed, color=
'black',
53 histtype=
"bar", rwidth=0.95)
56 plt.ylabel(
"Probability")
58 plt.ylabel(
"Frequency")
63 if not os.path.exists(
"images"):
66 for target_file
in args.files:
68 results = np.recfromtxt(target_file, delimiter=
',', loose=
True)
69 xlabel = DIM_LABELS[target_file.split(
".csv")[0].split(
"_")[-1]]
71 title = target_file.split(
"/")[-1].split(
"_")[0]
75 title = title +
" for " + SIMULATOR_LABELS[args.s]
78 fig.savefig(target_file.split(
".csv")[0] +
".pdf", format=
'pdf',
def histogram_plot(data, xlabel, title="", bins='auto', normed=False)