In the pylab mode of ipython in Linux, it is found that the graph drawn using matplotlib is not directly displayed, in addition, the Program does not display any error message, which is strange.
the original matplot configuration information was found after Google, you can easily solve this problem by adjusting the backend configuration in matplotlibrc
. The solution is as follows:
(1) find out the specific problem matplotlibrc
in [4]: Import matplotlib
in [5]: matplotlib. matplotlib_fname ()
out [5]: '/usr/local/lib/python2.7/dist-packages/matplotlib/MPL-data/matplotlibrc'
(2) adjust the matplotlibrc configuration as needed
Vim/usr/local/lib/python2.7/dist-packages/matplotlib/MPL-data/matplotlibrc
# 'module: // my_backend '
# backend: Finished
backend: qt4133
# If you are using the qt4agg backend, you can choose here
# To use the pyqt4 bindings or the newer pyside bindings
# The underlying qt4 toolkit.
# Backend. qt4: pyqt4 # pyqt4 | pyside
Backend. qt4: pyside # pyqt4 | pyside
For backend configuration information, you can use
In [3]: Import matplotlib. rcsetup as rcsetup
In [4]: rcsetup. all_backends
To obtain all supported backend lists.
Modify according to the above methodMatplotlibrc
Now, when you call matplotlib to draw a graph, you can see the graph display window.
Note: Set backend according to the specific environment. If QT is used, set backend. qt4 to pyqt4 or pyside.