Newer
Older
def count_substrings(substrings, strings):
from collections import defaultdict
results = defaultdict(int)
if strings == []:
return []
for sub in substrings:
for string in strings:
if sub.lower() in string.lower():
results[sub] += 1
return list(results.items())
def create(file, data, size, y_max, x_max):
import matplotlib.pyplot as plt
GNOME_BLUE = '#3A81CC'
DPI = float(90)
labels = []
values = []
for lab, val in data:
labels.append(lab)
values.append(val)
label_pos = []
x_pos = []
for x in range(len(labels)):
label_pos.append(x+BAR_START+BAR_WIDTH/2)
x_pos.append(x+BAR_START)
if y_max != 0:
plt.ylim((0,y_max))
plt.xlim((0,x_max))
else:
plt.gca().axes.get_yaxis().set_visible(False)
bars = plt.bar(left=x_pos, height=values, width=BAR_WIDTH, color=GNOME_BLUE)
for b in bars:
height = b.get_height()
ax.text(b.get_x()+b.get_width()/2., height, '%d'%int(height),
ha='center', va='bottom', color='black')
plt.savefig(file, dpi=DPI,transparent=False, pad_inches=0, frameon=None)