Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Choosing a matplotlib backend for a specific IPython profile

matplotlib has a config file and IPython has its own. Which one has precedence when it comes to setting things like matplotlib backends?

For example, say my config file for matplotlib says to use a specific backend, but then I modify my IPython startup or config files to use a different one. Which one would be used when I start IPython and import matplotlib?

More generally, what is the right way to set things up so that different profiles use different matplotlib backends or matplotlib configurations?

like image 817
Josh Avatar asked Apr 14 '14 14:04

Josh


People also ask

What is the default backend for matplotlib?

In modern matplotlib there is no "default backend", i.e. the rcParams['backend'] is set to a "sentinel". Upon importing matplotlib the first working backend from a candidate list ["macosx", "qt5agg", "qt4agg", "gtk3agg", "tkagg", "wxagg"] is chosen.

What is matplotlib use (' AGG ')?

Matplotlib is a plotting library. It relies on some backend to actually render the plots. The default backend is the agg backend. This backend only renders PNGs. On Jupyter notebooks the matplotlib backends are special as they are rendered to the browser.


1 Answers

IPython configuration is used, as IPython itself chooses the matplotlib backend.

For reference, see IPython:core/pylabtools.py:activate_matplotlib and notice how matplotlib.use(backend) is called explicitly.

like image 75
mtd Avatar answered Oct 21 '22 06:10

mtd