Matplotlib pyplot.title(string) returns error

前端 未结 8 551
名媛妹妹
名媛妹妹 2021-01-01 10:56

When I call pyplot.title(\'some string\') it throws the exception, \'str\' object is not callable\'. I copied the following from the matplotlib onl

相关标签:
8条回答
  • 2021-01-01 11:04

    I had the same problem. The code was fine, but in the interpreter, I had previoulsy used incorrect xlabel() calls. re-starting the interpreter (close and reopen it) was enough for me, no need to reinstall all python/matplotlib !

    0 讨论(0)
  • 2021-01-01 11:07

    It happened to me because I tried to do plot.title = "Some string" so that rewrote the title() method. That's the exact reason why it happens :) . As others have said you just need to restart the kernel, no need to reinstall.

    0 讨论(0)
  • 2021-01-01 11:08

    plt.title('xyz') :'str' object is not callable.

    just give a restart of your terminal/ide. That ll fix the issue .

    0 讨论(0)
  • 2021-01-01 11:13

    I've had this happen when I've previously accidentally plt.title = ''

    After that that function is no longer a function. Restarting python kernel or re-importing plt library can fix it.

    Not re-installing. Re-IMPORTING.

    0 讨论(0)
  • 2021-01-01 11:18

    I encountered the same problem where I wrote plt.title = "This is a sample plot" instead of plt.title("This is a sample plot"). I was getting the error:

    typeerror 'str' object is not callable

    Restarting the Spyder IDE fixed the issue for me.

    0 讨论(0)
  • 2021-01-01 11:23

    Had the same problem olben1, using ipython, anaconda and the --pylab flag. Reinstalled and it worked. Fwiw, using an anaconda env makes the uninstall/reinstall easier..

    0 讨论(0)
提交回复
热议问题