import numpy as np
import matplotlib.pyplot as plt

def graf(metoda, indexy):
	#best = np.loadtxt("best.txt", dtype=str)
	#metody = np.core.defchararray.add(np.core.defchararray.add(best[:,1], " "), best[:,3])

	data = None

	labels = ['0,2 m\n5 min', '0,2 m\n10 min', '0,2 m\n15 min', '0,2 m\n30 min', '0,5 m\n5 min', '0,5 m\n10 min', '0,5 m\n15 min', '0,5 m\n30 min', '1,0 m\n5 min', '1,0 m\n10 min', '1,0 m\n15 min', '1,0 m\n30 min']
	x = np.arange(len(labels))  # the label locations
	width = 0.9  # the width of the bars
	fig, ax = plt.subplots()
	ax.grid(axis="y")

	for i in range(len(indexy)):
		err = np.loadtxt("../results/lincoln/"+metoda+"_"+indexy[i]+".txt")
		rects = ax.bar(x + (width/len(indexy)*i) - width/2, err[:,2], width/len(indexy), label=indexy[i])
		#autolabel(rects)

	# Add some text for labels, title and custom x-axis tick labels, etc.
	ax.set_ylabel('Střední kvadratická chyba')
	ax.set_xlabel('Velikost časoprostorového okna')
	ax.set_title('Úloha s chodci '+metoda)
	ax.set_xticks(x)
	ax.set_xticklabels(labels)
	ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))
	plt.xticks(rotation=90)

	fig.tight_layout()

	plt.show()

graf("FreMEn", ["1", "2", "3", "4", "5"])
graf("HyT-EM", ["1", "2", "3", "4", "5"])
graf("Histogram", ["1", "2", "3", "4", "6"])
graf("EM-kC", ["1", "2", "3", "4", "5"])
graf("EM-vM", ["1", "2", "3", "4", "5"])

