I am new to python and trying to explore graphs, could you please help me understand if I can plot graphs on the console using matplotlib on a linux system that has no XSERVER running?
Thanks.
You can use matplotlib
with no X server by setting the backend to Agg
, PS
, PDF
or SVG
, Cairo
or GDK
(depending on what kind of file you wish to create). You can set the backend in your matplotlibrc
file, which, depending on your installation, may be in a directory such as ~/
or ~/.matplotlib
or ~/.config/matplotlib/
.
Alternatively, you can set the backend in the script itself.
Be sure to set the backend first, before importing other modules such as pyplot
:
import matplotlib
matplotlib.use("Agg")
See this SO question for examples.