How to set the matplotlib backend used by plot()
SageMath uses matplotlib
as its graphics engine and the module itself can work with many backends. But how can I set a GUI matplotlib backend to be used by the plot()
function and its friends, at least in the command-line interface? And is there a way to set a default backend?
In my setup, plot()
doesn't respect the backend set by the %matplotlib
magic, but matplotlib.pyplot.plot()
does. Even worse, the default backend creates a PNG image file and opens it in the system's viewer.
I'm on macOS 10.13 "High Sierra" running SageMath 9.1, the binary app version.
I don't have an answer, but few ideas. The
_rich_repr_
method ofGraphics2d
object is what tells to open the figure in the system's viewer. Maybe you can achieve what you want by extracting the matplotlib object from the Graphics2d object as in:Or you may check if changing the preferences of the display manager helps you: