【Python】Matplotlib

2023-01-31 python matplotlib

【重要】 python 2.7.11


////// HomePage

Http://matplotlib.org/index.html


////// install

# sudo yum install Python-matplotlib


已安装:

  python-matplotlib.x86_64 0:1.2.0-15.el7


作为依赖被安装:

  agg.x86_64 0:2.5-18.el7

  atlas.x86_64 0:3.10.1-10.el7

  blas.x86_64 0:3.4.2-5.el7

  lapack.x86_64 0:3.4.2-5.el7

  libgfortran.x86_64 0:4.8.5-4.el7

  libquadmath.x86_64 0:4.8.5-4.el7

  numpy.x86_64 1:1.7.1-11.el7

  python-nose.noarch 0:1.3.0-3.el7

  t1lib.x86_64 0:5.1.2-14.el7

  texlive-base.noarch 2:2012-38.20130427_r30134.el7

  texlive-dvipng.noarch 2:svn26689.1.14-38.el7

  texlive-dvipng-bin.x86_64 2:svn26509.0-38.20130427_r30134.el7

  texlive-kpathsea.noarch 2:svn28792.0-38.el7

  texlive-kpathsea-bin.x86_64 2:svn27347.0-38.20130427_r30134.el7

  texlive-kpathsea-lib.x86_64 2:2012-38.20130427_r30134.el7


////// using

[root@wode005 18.matplotlib]# python m001.py

Traceback (most recent call last):

  File "m001.py", line 1, in <module>

    import matplotlib as mpl

ImportError: No module named matplotlib


////// pip

# pip install matplotlib

Collecting matplotlib

  Downloading matplotlib-1.5.1.tar.gz (54.0MB)

    36% |███████████▉                    | 20.0MB 177kB/s eta 0:03:12


////// error

freetype: no  [The C/C++ header for freetype2 (ft2build.h)

                            could not be found.  You may need to install the

                            development package.]

                       png: no  [pkg-config infORMation for 'libpng' could not

                            be found.]

                     qhull: yes [pkg-config information for 'qhull' could not be

                            found. Using local copy.]


# yum install freetype-devel

# yum install libpng-devel


////// Reference

http://www.cnblogs.com/vamei/arcHive/2013/01/30/2879700.html



////// sample code

# a strait line: use pyplot functions


from matplotlib.pyplot import *


plot([0, 1], [0, 1])      # plot a line from (0, 0) to (1, 1)

title("a strait line")

xlabel("x value")

ylabel("y value")

savefig("m002.png")


相关文章