matplotlib is currently using tkagg which is a non-gui backend code example
Example: matplotlib is currently using agg
from matplotlib import pyplot
pyplot.plot(your_plot)
pyplot.savefig("output.png")
from matplotlib import pyplot
pyplot.plot(your_plot)
pyplot.savefig("output.png")