Plot doesn't seem to evaluate my function
I've got a custom function I wrote and I'm trying to plot it. Actually, I'm trying to do an xy density plot but the density plot function was flat (all blue). So I'm trying to plot in a single variable to see what's going on, and the result is all zeroes.
However, when I evaluate my function at several points, none of them are zero. Here's some code showing my function being evaluated at several points vs what plot gives me. Any idea what's going on?
tags = []
for i in range(12):
for j in range(12):
tags.append((i*8, j*8, 3))
def getdist((x0,y0,z0),(x1,y1,z1)):
return sqrt((x1-x0)^2+(y1-y0)^2+(z1-z0)^2.)
def sum_of_distances((x,y,z), tags, maxdist):
cumdist = 0
for tag in tags:
dist = getdist((x,y,z), tag)
if dist <= maxdist:
cumdist = cumdist + dist
return cumdist
#this shows we have real numbers
for i in range(10):
print sum_of_distances((i,1,1), tags, 30)
#this just shows a y value of 0 (x is 0 to 10)
plot(sum_of_distances((x,1,1), tags, 30),(x,0,10))