Solution to the problem that the image is not displayed in pylab mode of ipython in Linux

Source: Internet
Author: User

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 methodMatplotlibrcNow, 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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.