>>> import matplotlib.pyplot as plt
>>> fig = plt.figure()
>>> ax1 = fig.add_subplot(2,2,1)
>>> plt.show()
TypeError: Couldn't find foreign struct converter for 'cairo.Context'
What's this ... I was thinking of drawing a graph and playing ...
Distribution: 4.4.5-1-ARCH Python:Python 3.5.1
There was a similar example in the article Python matplotlib Cairo error, so I was able to solve it easily by following Sole. ..
--First, install python3-pyqt5.
#python3 in the official arch repository-python instead of pyqt5-It is called pyqt5.
sudo pacman -S python-pyqt5
--Check the directory to rewrite matplotlibrc.
>>>import matplotlib
>>>matplotlib.matplotlib_fname()
'/usr/lib/python3.5/site-packages/matplotlib/mpl-data/matplotlibrc'
--Rewrite the item of backend :.
matplotlibrc
# The default backend; one of GTK GTKAgg GTKCairo GTK3Agg GTK3Cairo
# CocoaAgg MacOSX Qt4Agg Qt5Agg TkAgg WX WXAgg Agg Cairo GDK PS PDF SVG
# Template.
# You can also deploy your own backend outside of matplotlib by
# referring to the module name (which must be in the PYTHONPATH) as
# 'module://my_backend'.
backend : qt5agg #I rewrote here. Originally backend: gtk3agg
--And ...
did it. I did it.
Recommended Posts