I have a very long code in Python so I can’t write it all here. Anyhow, the problem is that I’m plotting a function in the code with the semilogx command and everything works fine. However, if I switch to the plot command I got this error:
TypeError: ‘bool’ object is not callable
What do you think might cause the problem?
It seems that anywhere I use the plot command in the code I get the same error.
I tried plotting the first variable that I use in my code:
f=loadtxt(folder_out+"stars/stars"+str(output)+".txt",skiprows=2)
ids=f[:,0]
mass_star=f[:,1] # mass in Msun
x=f[:,2]
y=f[:,3]
z=f[:,4]
age=f[:,5] # age in Myr
plot(x,y,'.')
And the last line gives me the error. I’m sure I read the variable from the file, they have the same dimension.
Your error indicates that
plotis not a function, as you think it is, but abool(ie.TrueorFalse, the result of a boolean expression). This could be for a couple of reasons:boolto a variable namedplot(perhaps in a loop — remember that loops andifstatements in Python do not create a new scope)from whatever import *statements, one of which imports a nameplotwhich is clobbering the one frompylab(it might even be afrom whatever import plotthat you haven’t noticed)You could try to narrow it down by a simple text search for
plotto see if you’re doing it explicitly. You could also remove imports and strip down your script until it works as expected, and try to identify the problematic line.