If you include the following code at the top of your script, matplotlib
will run inline when in an IPython
environment (like jupyter, hydrogen atom plugin...), and it will still work if you launch the script directly via command line (matplotlib
won't run inline, and the charts will open in a pop-ups as usual).
from IPython import get_ipython
ipy = get_ipython()
if ipy is not None:
ipy.run_line_magic('matplotlib', 'inline')