Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

automatically run %matplotlib inline in jupyter qtconsole

Is there a way to change the config file to make jupyter qtconsole run the following command on startup?:

%matplotlib inline
like image 530
Alexander Avatar asked Oct 20 '15 04:10

Alexander


People also ask

What is the use of %Matplotlib inline in Jupyter notebook?

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.

What can I use instead of %Matplotlib inline?

show() . If you do not want to use inline plotting, just use %matplotlib instead of %matplotlib inline .

What does %Matplotlib Inline do in Python?

%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.

Is %Matplotlib Inline still needed?

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.


3 Answers

Add this line to the ipython_config.py file (not the ipython_qtconsole_config.py file):

c.InteractiveShellApp.matplotlib = 'inline'
like image 83
screenpaver Avatar answered Nov 02 '22 18:11

screenpaver


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')
like image 40
Amit Moscovich Avatar answered Nov 02 '22 18:11

Amit Moscovich


Open the file ~/.ipython/profile_default/ipython_config.py, and

c.InteractiveShellApp.code_to_run = ''

==>

c.InteractiveShellApp.code_to_run = '%pylab inline'
like image 45
Dean Wong Avatar answered Nov 02 '22 19:11

Dean Wong