I've decided to setup a custom matplotlibrc
, and thus I need to pick a backend for matplotlib
. What is the best one in terms of not needing to install other additional packages?
I tend to use matplotlib
via ipython --pylab
, so I want interactive window based plots (when I don't I can switch to Agg
).
I've tried WXAgg
, but this requires (sensibly enough) WX.
Both
Agg
andTkAgg
do not require any dependencies beyond Python's standard library.I have had some issues with
TkAgg
and multi-threading, so if you only need to save to files (and notplt.show()
), I would recommend usingAgg
instead (just replace it whereTkAgg
appears below).Either add the following line to your
~/.config/matplotlib/matplotlibrc
:Or the following lines to your python file:
PyQt5 is the best backend for Matplotlib from my knowledge. It allows all the edits even after you run your program. To use it,
put this first before calling
N.B. you need to install PyQt5
for installation via pip, run command
I prefer inline plots with matplotlib to plots in a separate window because it makes it easier to see what I'm doing when I'm fine tuning the Python code.
Python IDE for scientists (spyder) can do inline plotting. To try out this feature open the terminal and type:
or
After the ipython prompt in the IPython console copy/paste the below code and press the Enter key to run it.
Atom text editor with the Hydrogen package for Atom installed can also do inline plotting. I find the Atom interface more complicated to configure than Spyder in which inline plotting with matplotlib works out of the box. I got started with inline plotting in Atom because I wanted to use Atom to make inline plots with other programming languages too.