问题
I'm using Jupyter Notebook and trying to make graphs of igraph
appear on matplotlib
plots. I've found that one of possible solutions is to create GraphArtist class class that draws igraph graphs but, unfortunately, only Cairo-based backends are supported. When I try to use it, no plot is displayed
import matplotlib
matplotlib.use("cairo")
fig = plt.figure()
ax = plt.gca()
plt.plot(range(10), [i**1.5 for i in range(10)]) #a simplified version of my diagram
plt.show()
and I get this warning:
UserWarning: Matplotlib is currently using cairo, which is a non-GUI backend, so cannot show the figure.
And, indeed, I can see that it's not on the list:
>>> print ("Non Gui backends are:", matplotlib.rcsetup.non_interactive_bk)
>>> print ("Gui backends are", matplotlib.rcsetup.interactive_bk)
Non Gui backends are: ['agg', 'cairo', 'pdf', 'pgf', 'ps', 'svg', 'template']
Gui backends are: ['GTK3Agg', 'GTK3Cairo', 'MacOSX', 'nbAgg', 'Qt4Agg', 'Qt4Cairo', 'Qt5Agg', 'Qt5Cairo', 'TkAgg', 'TkCairo', 'WebAgg', 'WX', 'WXAgg', 'WXCairo']
What can I do to enable this cairo
backend?
Additional question: there is matplotlib.use("cairo.pdf")
used in a link, can it affect an output of script there?
来源:https://stackoverflow.com/questions/63536495/how-can-i-enable-cairo-backend-while-plotting-igraph-objects-on-matplotlib