# BarTweets3
# Add random bar charts to compare

# Adapted from Jer Thorp
# http:#blog.blprnt.com/blog/blprnt/your-random-numbers-getting-started-with-processing-and-data-visualization

from Processing import *
window(800,600)

# Assemble and draw a bar graph
def barGraph(nums, y):
	# Make a list of number counts filled with 0's
	counts = [0 for i in range(100)]
 
	# Tally the counts
	for i in range(len(nums)):
		counts[ nums[i] ] += 1

	# Draw the bar graph
	for i in range( len(counts) ):
		rect(i * 8, y, 8, -counts[i] * 10)

	# Draw the bar graph
	for i in range( len(counts) ):
		fill(counts[i] * 30, 0, 0)
		rect(i * 8, y, 8, -counts[i] * 10)

# Load strings and convert to integers
f = open("numbers.txt", "r")
snumbers = f.readlines()
f.close()
numbers = [ int(s) for s in snumbers ]

# Draw the bar graph
barGraph(numbers, 100)
  
# Add bar graphs of random data
for l in range(5):
	for i in range(len(numbers)):
		numbers[i] = ceil(random(0,99)) 
	barGraph(numbers, (l+2)*100)

