Run python script in IPython with inline / embedded plots

后端 未结 2 1308
天命终不由人
天命终不由人 2021-02-13 15:54

I\'d like to have a batch file in one folder with a python script. The batch file should call the script in IPython and plot the figures inline / embed

相关标签:
2条回答
  • 2021-02-13 16:16

    Greg answered it here:
    Start ipython qtconsole as interactive interpreter after script execution

    It works using the -m flag

    ipython qtconsole --matplotlib inline -m example_plots
    

    or

    ipython qtconsole --pylab inline -m example_plots
    

    But I do not know, what makes the difference between those two options pylab inline and matplotlib inline. From here I figure, that I'd rather use --matplotlib inline

    Even adding the file ending it does what I want to, but it complains about unknown failure after execution.

    pyplot.show(block=True) will give and unknown failure, too

    0 讨论(0)
  • 2021-02-13 16:18

    How to run a python script with IPython, showing plots embedded?

    • You need to use the qt console.
    • Run ipython qtconsole <yourscript.py>.
    • If you have jupyter installed, the better.
    • Run jupyter qtconsole <yourscript.py>

    Do I need to use pylab or can I just import matplotlib.pyplot in the script?

    • Run %matplotlib inline prior to importing matplotlib.pyplot.

    Is %pylab inline / %matplotlib inline to be used or not?

    • Yes. But pylab has been depreciated. Use %matplotlib inline.
    0 讨论(0)
提交回复
热议问题