python 初识Matplotlib

Matplotlib 是一个风格类似 Matlab 的基于 Python 的绘图库。它提供了一整套和matlab相似的命令API,十分适合交互式地进行制图。而且我们也可以方便地将它作为绘图控件,嵌入GUI应用程序中。

我们可以在下面的网址找到matplotlib的安装使用教程:
https://matplotlib.org/users/installing.html

在windows下最简单的安装方式就是通过下面的命令行:

python -m pip install -U pip
python -m pip install -U matplotlib

安装界面:
python 初识Matplotlib

我们绘制图形主要用到两个库,matplotlib.pyplot和numpy。

我们可以通过命令行终端导入matplotlib来验证其是否安装成功,如果没有得到任何错误,那么安装就ok了。

C:\Users\86448>python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>>

我们可以在这个网址找到matplotlib可以绘制的图形的一些官方案例:
https://matplotlib.org/gallery/index.html

python 初识Matplotlib