I am trying to build a histogram. So far I have coded the following:
from Tkinter import *

def plot(data):
numberOfBins = len(data)
root = Tk()
width, height = 200, 630 #taille de la fenetre
die = Canvas(root, width = width, height = height)
die.pack()
numberOfStripes = 2 * numberOfBins + 1
barWidth = width/numberOfStripes
unitHeight = 300/(max([datum[1] for datum in data]) + 2)
for i in range(numberOfBins):
die.create_rectangle(
(2 * i + 1) * barWidth, unitHeight,
(2 * i + 2) * barWidth, (data[1] + 1) * unitHeight,
fill = 'blue')
root.mainloop()

if __name__ == '__main__':
plot([,
,
])

The problem is that the program creates 3 rectangles (which I plan to use to create my histogram) but the bars are in the opposite side (my numbers are positive but they show as if they were negative).

Also I would like to know how to name each bar.

Could someone help me with these 2 issues?

Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.