Is there a way to change the config file to make jupyter qtconsole run the following command on startup?:
%matplotlib inline
You can use the magic function %matplotlib inline to enable the inline plotting, where the plots/graphs will be displayed just below the cell where your plotting commands are written. It provides interactivity with the backend in the frontends like the jupyter notebook.
show() . If you do not want to use inline plotting, just use %matplotlib instead of %matplotlib inline .
%matplotlib inline sets the backend of matplotlib to the 'inline' backend: With this backend, the output of plotting commands is displayed inline within frontends like the Jupyter notebook, directly below the code cell that produced it. The resulting plots will then also be stored in the notebook document.
The end point is that it is not necessary anymore, however, it is still convention to keep your code clean and call on the plot that you made, and definitely recommended.
Add this line to the ipython_config.py
file (not the ipython_qtconsole_config.py
file):
c.InteractiveShellApp.matplotlib = 'inline'
In your ipython_config.py
file you can specify commands to run at startup (including magic % commands) by setting c.InteractiveShellApp.exec_lines
. For example,
c.InteractiveShellApp.exec_lines = """
%matplotlib inline
%autoreload 2
import your_favorite_module
""".split('\n')
Open the file ~/.ipython/profile_default/ipython_config.py
, and
c.InteractiveShellApp.code_to_run = ''
==>
c.InteractiveShellApp.code_to_run = '%pylab inline'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With