pyhton中Matplotlib模块

pyhton中Matplotlib模块

概述

Matplotlib 是 Python 的绘图库。 它可与 NumPy 一起使用,提供了一种有效的 MatLab 开源替代方案。 它也可以和图形工具包一起使用,如 PyQt 和 wxPython

安装

windows下

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

实例

import numpy as np 
from matplotlib import pyplot as plt 
 
x = np.arange(1,11) 
y =  2  * x +  5 
plt.title("Matplotlib demo") 
plt.xlabel("x axis caption") 
plt.ylabel("y axis caption") 
plt.plot(x,y) plt.show()

以上实例中,np.arange() 函数创建 x 轴上的值。y 轴上的对应值存储在另一个数组对象 y 中。 这些值使用 matplotlib 软件包的 pyplot 子模块的 plot() 函数绘制。

图形由 show() 函数显示。
在这里插入图片描述

详细见:https://www.runoob.com/numpy/numpy-matplotlib.html

发布了465 篇原创文章 · 获赞 694 · 访问量 96万+

猜你喜欢

转载自blog.csdn.net/mao_hui_fei/article/details/103821082