How do I get interactive plots again in Spyder/IPython/matplotlib?

前端 未结 5 1879
逝去的感伤
逝去的感伤 2020-11-30 18:25

I upgraded from Python(x,y) 2.7.2.3 to 2.7.6.0 in Windows 7 (and was happy to see that I can finally type function_name? and see the docstring in the Object Ins

相关标签:
5条回答
  • 2020-11-30 18:45

    As said in the comments, the problem lies in your script. Actually, there are 2 problems:

    • There is a matplotlib error, I guess that you're passing an argument as None somewhere. Maybe due to the defaultdict ?
    • You call show() after each subplot. show() should be called once at the end of your script. The alternative is to use interactive mode, look for ion in matplotlib's documentation.
    0 讨论(0)
  • 2020-11-30 18:47

    Change the backend to automatic:

    Tools > preferences > IPython console > Graphics > Graphics backend > Backend: Automatic

    Then close and open Spyder.

    0 讨论(0)
  • 2020-11-30 19:05

    After applying : Tools > preferences > Graphics > Backend > Automatic Just restart the kernel

    And you will surely get Interactive Plot. Happy Coding!

    0 讨论(0)
  • 2020-11-30 19:08

    You can quickly control this by typing built-in magic commands in Spyder's IPython console, which I find faster than picking these from the preferences menu. Changes take immediate effect, without needing to restart Spyder or the kernel.

    To switch to "automatic" (i.e. interactive) plots, type:

    %matplotlib auto
    

    then if you want to switch back to "inline", type this:

    %matplotlib inline
    

    (Note: these commands don't work in non-IPython consoles)

    See more background on this topic: Purpose of "%matplotlib inline"

    0 讨论(0)
  • 2020-11-30 19:10

    This is actually pretty easy to fix and doesn't take any coding:

    1.Click on the Plots tab above the console. 2.Then at the top right corner of the plots screen click on the options button. 3.Lastly uncheck the "Mute inline plotting" button

    Now re-run your script and your graphs should show up in the console.

    Cheers.

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