Matplotlib.style ERROR: 'str' object is not callable

import matplotlib.pyplot as plt
import matplotlib.style as style
style.use('ggplot')
plt.plot([2, 4, 6], [10, 15, 5])
plt.show()

style.use('default')
plt.plot([2, 4, 6], [10, 15, 5])
plt.show()

I thought that there is nothing wrong with this (I got exactly the same answer with the answer provided by DQ), but I kept getting the error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-5feb067047cc> in <module>
      1 import matplotlib.pyplot as plt
      2 import matplotlib.style as style
----> 3 style.use('ggplot')
      4 plt.plot([2, 4, 6], [10, 15, 5])
      5 plt.show()

TypeError: 'str' object is not callable

Can anyone help me please? Thank you.

1 Like

You must have done

style.use = 'ggplot'

instead of

style.use('ggplot')

Now you will have to restart and re-login or

reload matplotlib package