I am analyzing a dataset in Python for strictly learning purpose. In the code below that I wrote, I am getting some errors which I cannot get rid off. Here is the code first:

plt.plot(decade_mean.index, decade_mean.values, 'o-',color='r',lw=3,label = 'Decade Average')
plt.scatter(movieDF.year, movieDF.rating, color='k', alpha = 0.3, lw=2)

I am getting the following errors:

1. TypeError: 'str' object is not callable
2. NameError: name 'remove_border' is not defined

Also, the label='Decade Average' is not showing up in the plot.

What confuses me most is the fact that in a separate code snippet for plots (see below), I didn't get the 1st error above, although remove_border was still a problem.

plt.hist(movieDF.rating, bins = 5, color = 'blue', alpha = 0.3)

Any explanations of all or some of the errors would be greatly appreciated. Thanks

Following the comments, I am posting the data and the traceback below: decade_mean is given below.

1970    8.925000
1980    8.650000
1990    8.615789
2000    8.378947
2010    8.233333
Name: rating, dtype: float64


TypeError                                 Traceback (most recent call last)
<ipython-input-361-a6efc7e46c45> in <module>()
      1 plt.plot(decade_mean.index, decade_mean.values, 'o-',color='r',lw=3,label = 'Decade Average')
      2 plt.scatter(movieDF.year, movieDF.rating, color='k', alpha = 0.3, lw=2)
----> 3 plt.xlabel('Year')
      4 plt.ylabel('Rating')
      5 remove_border()

TypeError: 'str' object is not callable

I have solved remove_border problem. It was a stupid mistake I made. But I couldn't figure out the problem with the 'str'.

  • $\begingroup$ Could you provide an example which reproduces the errors (with minimal data samples)? Also, posting full tracebacks is extremely helpful to diagnose a problem. Otherwise we can only guess. $\endgroup$ Commented Apr 20, 2015 at 17:12
  • $\begingroup$ use %matplotlib inline before your code $\endgroup$ Commented Jan 9, 2023 at 22:04

2 Answers 2


Seems that remove border is not defined. You have to define the function before used.

I do not know where the string error comes, is not clear to me. If you post the full traceback it will be clearer.

Finally your label is not show because you have to call the method plt.legend()


Seems to me that remove_border() is not being recognized as a function. Seeing how you haven't listed a package it belongs to, did you implement this yourself? Python is guessing that remove_border is a string and you're trying to "call it" - treat it like a function. The 2nd error is saying the same thing, the function remove_border isn't defined anywhere that Python can find it.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.