-
Notifications
You must be signed in to change notification settings - Fork 0
/
drawHistograms.py
29 lines (27 loc) · 978 Bytes
/
drawHistograms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import numpy as np
import os
import matplotlib.pyplot as plt
def main(bow, detectorName, dictionarySize):
dir = "BOW/Diagrams/" + detectorName
if not os.path.exists(dir):
os.makedirs(dir)
ymax = np.max(bow)
for u in range(3): # len(bow)):
p = "BOW/Diagrams/" + detectorName + "/" + str(u) + ".png"
if os.path.isfile(p):
continue
currentbow = bow[u]
bin_positions = list(range(len(currentbow)))
bins_art = plt.bar(bin_positions, currentbow)
fig = plt.gcf()
fig.set_size_inches(9, 6, forward=True)
plt.xlim(-1, dictionarySize + 5)
plt.ylim(0, ymax)
plt.ylabel("Встречаемость")
plt.xlabel("Классы")
plt.tight_layout()
plt.title(detectorName + " BOW " + " for image " + str(u))
plt.savefig(p)
plt.clf()
print("Have drawn for ", u)
print("Ended to draw diagrams")