cmbant/getdist

Setting the matplotlib backend in getdist/plots.py

Closed this issue · 4 comments

This line forces matplotlib to use the given version of the backend.
matplotlib.use('Agg', warn=False)
Because of this the command plt.show() does not work anymore. Is there any way around it? I want to be able to see the plot before I save it to a figure.

Can you change the backend using “force” after loading getdist? (usually for testing I'd use a Jupyter notebook, will work there for viewing)

I can however I am currently using Ubuntu 20.04 and I am rather new to this OS. How do I find out which backend is the default one? I tried some choices I saw on the internet but they return errors.

Out of curiosity, why does that line exist in the code? I mean is there something particular about the backend which is used in the mentioned file?

See e.g. https://matplotlib.org/3.3.3/tutorials/introductory/usage.html#what-is-a-backend

The line is there so that if you generate plots on cluster, it will just work (rather than trying to use a non-existing graphical interactive session). I would agree that the code shouldn't really be changing the backend, but not sure what a better solution for this is. It's designed to also work with the other common use cases of using a Jupyter notebook and the getdist GUI.

In cd95fdf I changed it to only force the backend on linux machines with no display set.