Beispiel #1
0
    def plot(self, filename):
        xaxis = range(4)
        bars = [
            self.positiveTotal, self.negativeTotal, self.neutralTotal,
            self.naTotal
        ]
        labels = ["positive", "negative", "neutral", "unsure"]

        minY = 0
        maxY = 0

        for y in bars:
            if y > maxY:
                maxY = y
            if y < minY:
                minY = y

        fig = plt.figure(figsize=(8, 6))
        plt.subplots_adjust(bottom=0.15, left=0.10, right=0.90, top=0.95)

        plt.ylim([minY, maxY])
        plt.xticks(xaxis,
                   labels,
                   rotation='vertical',
                   size='small',
                   ha='center')
        rects = plt.bar(xaxis, bars, 0.5, alpha=0.4, color='b', align="center")
        autolabel(rects)
        rects[0].set_color('g')
        rects[1].set_color('r')
        rects[2].set_color('y')
        rects[3].set_color('0.5')
        plt.savefig(filename)
        plt.clf()
        plt.close()
Beispiel #2
0
	def plot(self, filename):
		xaxis = range(5)
		self.pleasantness, self.attention, self.sensitivity, self.aptitude, self.polarity
		bars = [self.pleasantness, self.attention, self.sensitivity, self.aptitude, self.polarity]
		labels = ["pleasantness", "attention", "sensitivity", "aptitude", "polarity"]

		minY = 0
		maxY = 0
		
		for y in bars:
			if y > maxY:
				maxY = y
			if y < minY:
				minY = y
		
		fig = plt.figure(figsize=(8, 6))
		plt.subplots_adjust(bottom=0.18, left=0.05, right=0.95, top=0.95)

		plt.ylim([minY,maxY])
		plt.xticks(xaxis, labels, rotation='vertical', size='small', ha='center')
		plt.axhline(0, color='black')
		rects = plt.bar(xaxis, bars, 0.5, alpha=0.4, color='b', align="center")
		autolabel(rects)
		rects[0].set_color('b')
		rects[1].set_color('r')
		rects[2].set_color('m')
		rects[3].set_color('g')
		rects[4].set_color('y')
		plt.savefig(filename)
		plt.clf()
		plt.close()
Beispiel #3
0
	def plot(self, filename):
		xaxis = range(4)
		bars = [self.positiveTotal, self.negativeTotal, self.neutralTotal, self.naTotal]
		labels = ["positive", "negative", "neutral", "unsure"]

		minY = 0
		maxY = 0
		
		for y in bars:
			if y > maxY:
				maxY = y
			if y < minY:
				minY = y

		fig = plt.figure(figsize=(8, 6))
		plt.subplots_adjust(bottom=0.15, left=0.10, right=0.90, top=0.95)

		plt.ylim([minY,maxY])
		plt.xticks(xaxis, labels, rotation='vertical', size='small', ha='center')
		rects = plt.bar(xaxis, bars, 0.5, alpha=0.4, color='b', align="center")
		autolabel(rects)
		rects[0].set_color('g')
		rects[1].set_color('r')
		rects[2].set_color('y')
		rects[3].set_color('0.5')
		plt.savefig(filename)
		plt.clf()
		plt.close()
Beispiel #4
0
    def _add_to_autolabel(text, center=False):

        if not isinstance(text, (str, unicode)):
            return
        ret = u(autolabel()).split('\n')
        ret.insert(1, text)
        ret = '\n'.join(ret).rstrip('\n')
        if center:
            ret = ('<div align="center" '
                   'style="margin:0px;padding:0px">{}</div>').format(ret)
        return ret
Beispiel #5
0
    p_list[participant] = []

for month, stat in stats.items():
    for participant in participants:
        try:
            p = stat[participant]
        except:
            p = 0
        p_list[participant].insert(0, p)
    m_list.insert(0, month)

ind = np.arange(len(m_list)) * (1 + width * len(participants))
i = int((1 - len(participants)) / 2)
for participant in participants:
    p = plt.bar(ind + width * (i - 1 / 2), p_list[participant], width)
    autolabel(p)
    plots.append(p[0])
    i = i + 1
plt.ylabel('Messages')
plt.title('Messages per month')
plt.xticks(ind, m_list)
plt.legend(plots, participants)

total = 0
for participant in participants:
    sub = sum(p_list[participant])
    print(participant.ljust(participant_name_len_max + 1) + str(sub))
    total = total + sub
print()
print("Total messages: " + str(total))
plt.show()