import numpy as np
import matplotlib.pyplot as plt

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

	data = None

	labels = ['Trén.', 'Test 1', 'Test 2', 'Test 3', 'Test 4', 'Test 5']
	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/tunnelers/"+metoda+"_"+indexy[i]+".txt")
		rects = ax.bar(x + (width/len(indexy)*i) - width/2, err[:,0], 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_title('Úloha s vytížeností - metoda '+metoda)
	ax.set_xticks(x)
	ax.set_xticklabels(labels)
	ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))

	fig.tight_layout()

	plt.show()

#graf("FreMEn", ["1", "2", "3", "4", "5"])
#graf("HyT-EM", ["1", "2", "3", "4", "5"])
graf("Histogram", ["1", "4", "12", "24"])
graf("EM-kC", ["5", "10", "15", "20", "25", "30"])
graf("EM-vM", ["5", "10", "15", "20", "25", "30"])
#graf("MM-kC", ["5", "10"])
graf("MM-vM", ["2", "4", "6"])
graf("Adaboost", ["1", "2", "3", "4"])

