basically here is a code, what the question asked to do is to create a graph in quickdraw using the data given to us. now the problem is when i run the program it gives me a few errors. i am new at this and any help would be appreciated. example data is:

Medal Count by Country for the 2010 Olympics
Country,Gold,Silver,Bronze,Total
US,9,15,13,37
GE,10,13,7,30
CA,14,7,5,26
NO,9,8,6,23
AU,4,6,6,16
RF,3,5,7,15
KO,6,6,2,14
CH,5,2,4,11
SW,5,2,4,11
FR,2,3,6,11

# this program basically reads the input from the user, putting/storing it in blank lists which are then graphed
# on quickdraw to show the data collected. user also inputs the graph title and other information which should be included in the data/.txt file.  
import sys
import math

#
combinedlist = []
def main():
#1
	inputline = readinput()
	printtitle(inputline)
	drawgraphbase()
#2	
	inputline = readinput()
#	colorgen(inputline)
	printlegendandbottom(inputline)
#3	
	inputline = readinput()
	combinedlist = readalllines(inputline)
#3to the end
	seperatedbottomwords(combinedlist)
	max,min = findmaxandmin(combinedlist)
	generatescalesandbars(max,combinedlist)
	sys.stderr.write("done")
	sys.stderr.write(str("\n"))	
# define a function to read the input from the user and strip it. 
def readinput():
	inputline = input().rstrip()
	return inputline

##
##print the title
##
xlocationoftitle = 250
ylocationoftitle = 80
GRAPHTOP = 100
GRAPHLEFT = 100
GRAPHRIGHT = 700
GRAPHBOTTOM = 500
SCALEGAP = 80

def printtitle(title):

	print("text" + " " +  "\"" + str(title) + "\"" + " " + str(xlocationoftitle) + " " + str(ylocationoftitle))

##
##read input and split it into lists
##
	
def splitline(line):
	inputlinelist = line.split(",")
	return inputlinelist

##
##draw the graphbase.
##

def drawgraphbase():
	scaleline0xposition = GRAPHBOTTOM
	scaleline1xposition = GRAPHBOTTOM-SCALEGAP
	scaleline2xposition = GRAPHBOTTOM-(2*SCALEGAP)
	scaleline3xposition = GRAPHBOTTOM-(3*SCALEGAP)
	scaleline4xposition = GRAPHBOTTOM-(4*SCALEGAP)
	scaleline5xposition = GRAPHBOTTOM-(5*SCALEGAP)
	scaletip = GRAPHLEFT-5

	print("line" + " " + str(GRAPHLEFT) + " " + str(GRAPHTOP) + " " + str(GRAPHLEFT) + " " + str(GRAPHBOTTOM))
	print("line" + " " + str(GRAPHLEFT) + " " + str(GRAPHBOTTOM) + " " + str(GRAPHRIGHT) + " " + str(GRAPHBOTTOM))
	print("line"  + " " + str(GRAPHRIGHT) + " " + str(GRAPHBOTTOM) + " " + str(GRAPHRIGHT) + " " + str(GRAPHTOP))

	##draw the scale lines
	print("line" + " " + str(scaletip) + " " + str(scaleline0xposition) + " " + str(GRAPHRIGHT) + " " + str(scaleline0xposition))
	print("line" + " " + str(scaletip) + " " + str(scaleline1xposition) + " " + str(GRAPHRIGHT) + " " + str(scaleline1xposition))
	print("line" + " " + str(scaletip) + " " + str(scaleline2xposition) + " " + str(GRAPHRIGHT) + " " + str(scaleline2xposition))
	print("line" + " " + str(scaletip) + " " + str(scaleline3xposition) + " " + str(GRAPHRIGHT) + " " + str(scaleline3xposition))
	print("line" + " " + str(scaletip) + " " + str(scaleline4xposition) + " " + str(GRAPHRIGHT) + " " + str(scaleline4xposition))
	print("line" + " " + str(scaletip) + " " + str(scaleline5xposition) + " " + str(GRAPHRIGHT) + " " + str(scaleline5xposition))

##
##print the legend and graphbottom of the graph
##

def printlegendandbottom(line):

	legendcolorxposition = 725
	legendcoloryposition = 240
	legendcolorwidth = 10
	legendcolorheight = 10

	legendxposition = 750
	legendyposition = 250

	wordgap = 20

	bottomxposition = 350
	bottomyposition = 550

	linelist = splitline(line)
	
	
	


	i=0
	while i < len(linelist):
		if i == 0:
			print("text" + " " + "\"" + str(linelist[i]) + "\"" + " " + str(bottomxposition) + " " + str(bottomyposition))
			
		else:
			
			print("text" + " " + "\"" + str(linelist[i]) + "\"" + " " + str(legendxposition) + " " + str(legendyposition))
			print("fillrect" + " " + str(legendcolorxposition) + " " + str(legendcoloryposition) + " " + str(legendcolorwidth) + " " +str(legendcolorheight))
			legendyposition = legendyposition + wordgap
			legendcoloryposition = legendcoloryposition + wordgap
		i = i + 1



#################################################################
#read all lines after the second line of the document

def readalllines(line):
	
	combinedlist = []

	while (len(line) != 0) :
		linelist = splitline(line)
		combinedlist.append(linelist)
		line = readinput()
	
	return combinedlist	
	




#seperate and print the words at the bottom

def seperatedbottomwords(combinedlist):

	
	bottomwordxposition = 100
	bottomwordyposition = 525
	numbersofvaluelists = len(combinedlist)
	bottomwordsgap = ((GRAPHRIGHT - GRAPHLEFT) / numbersofvaluelists)
	bottompic =  GRAPHBOTTOM + 10
	bottompicxposition = GRAPHLEFT
	
	i = 0
	while i <  numbersofvaluelists:
		print("line" + " " + str(bottompicxposition) + " " + str(GRAPHBOTTOM) + " " + str(bottompicxposition) + " " + str(bottompic))
		bottompicxposition = bottompicxposition + bottomwordsgap
		i = i + 1
	
	i = 0
	j = 0
	while j < numbersofvaluelists:
		print("text" + " " + "\"" + str(combinedlist[j][i]) + "\"" + " " + str(bottomwordxposition) + " " + str(bottomwordyposition))
		bottomwordxposition = bottomwordxposition + bottomwordsgap
		j = j + 1


		
###generate the scales

def findmaxandmin(allinputs):	
	max = 0
	min = 0
	j = 0
	while j < len(allinputs):
		list = allinputs[j]
		i = 1
		while i < len(list):
			if max < int(list[i]):
				max = int(list[i])
				
			if min > int(list[i]):
				min = int(list[i])
				
			i = i + 1
		j = j + 1
	return max,min
#################################################
def generatescalesandbars(max,allinputs):
	scalesvaluesygap = (GRAPHTOP-GRAPHBOTTOM)/5
	yaxismax= 10**math.ceil(math.log10(max))
#	sys.stderr.write(str(yaxismax))
	valuesgap = 0
	scalesygap = 0
	scaletip = GRAPHLEFT-5
	
	
	
	if max <= (yaxismax/4) :
		yaxismax = yaxismax/4
	if max <= (yaxismax/2) :
		yaxismax = yaxismax/2
		
	
	
	scalevalues = (yaxismax/5)

	
###################################################
	i = 0
	name = 0
	while i < 6:
		print("text" + " \"" + str(valuesgap*scalevalues) + "\" " + str(scaletip) + " " + str(GRAPHBOTTOM+(scalesygap*scalesvaluesygap) + " " + " \""+ str(name) + " \""+ " " + "right"))
		valuesgap = valuesgap + 1
		scalesygap = scalesygap + 1
		name = name + 1
		i = i + 1
	
	
	
	
####################################################
	pixelsperunit = (GRAPHTOP-GRAPHBOTTOM)/yaxismax
	sys.stderr.write(str(pixelsperunit))
	sys.stderr.write(str("\n"))
	
	numbersofvaluelists = len(allinputs)
	
	bottomwordsgap = ((GRAPHRIGHT - GRAPHLEFT) / numbersofvaluelists)
	sys.stderr.write("wordgap: " + str(bottomwordsgap))
	sys.stderr.write(str("\n"))
	
	
	j = 0
	while j < len(allinputs):
		list = allinputs[j]
		
		sys.stderr.write("debug")
		sys.stderr.write(str("\n"))

		barwidth = bottomwordsgap/(len(list)+2)
		barxposition = (GRAPHLEFT + barwidth +(j * ((GRAPHRIGHT - GRAPHLEFT)/len(allinputs))))

		i = 1	
		while  i < len(list):
						
			sys.stderr.write("barx: " + str(barxposition))
			sys.stderr.write(str("\n"))
			
			baryposition = GRAPHBOTTOM + (pixelsperunit*int(list[i]))
			sys.stderr.write("value: "+str(list[i]))
			sys.stderr.write(str("\n"))
			
			sys.stderr.write("bary: "+str(baryposition))
			sys.stderr.write(str("\n"))
			
			barwidth = bottomwordsgap/(len(list)+2)
			
			sys.stderr.write("list#: "+str((len(list)+2)))
			sys.stderr.write(str("\n"))
			
			sys.stderr.write("width: "+str(barwidth))
			sys.stderr.write(str("\n"))
			
			barlength = GRAPHBOTTOM - baryposition
			sys.stderr.write("length"+str(barlength))
			sys.stderr.write(str("\n"))
			
			barposition = (barxposition + (i-1)*barwidth)+5
			
			sys.stderr.write("barposition: "+str(barposition))
			sys.stderr.write(str("\n"))
			sys.stderr.write(str("\n"))
			
			print("fillrect" + " " + str(barposition) + " " + str(baryposition) + " " + str(barwidth) + " " + str(barlength))
			i = i + 1
			
		j = j +1
###################################################
main()

and the traceback errors were:
Traceback (most recent call last):
File "a3.py", line 282, in <module>
main()
File "a3.py", line 30, in main
generatescalesandbars(max,combinedlist)
File "a3.py", line 215, in generatescalesandbars
print("text" + " \"" + str(valuesgap*scalevalues) + "\" " + str(scaletip) + " " + str(GRAPHBOTTOM+(scalesygap*scalesvaluesygap) + " " + " \""+ str(name) + " \""+ " " + "right"))
TypeError: unsupported operand type(s) for +: 'float' and 'str'

I do not know which value you have incorrect, but it is easier to say instead

print('text "%s" %s %s "%s" right' % 
      (valuesgap*scalevalues, scaletip, GRAPHBOTTOM+(scalesygap*scalesvaluesygap), name))

thank you it worked ! another question if i wanted to use a colors list such as this one

colors = ["color 0 0 255","color 0 255 0","color 255 0 0","color 255 255 0","color 155 255 0","color 255 155 0","color 0 155 255","color 0 200 210","color 200 255 120","color 100 200 255","color 110 220 255","color 24 145 200","color 10 100 240","color 199 99 201","color 181 247 111"]

how would i go about putting that in the same loop as the bars so that it would show in different colors?

thanks for all your help !

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.