Python 画图

来源:互联网 发布:关口知宏对中国的感觉 编辑:程序博客网 时间:2024/05/18 02:47
导入两个包
import numpy as npimport matplotlib.pyplot as plt


首先讨论numpy

numpy中几个实用的函数

<pre name="code" class="python">k = np.arrage(1, 11)#返回1到20的数组array对比 k = range(1, 11)#返回1到20的list

x = np.linspace(1, 10, 100) #1到10内均匀生成100个点y = np.sin(x)plt.plot(x, y)plt.title('Sin')plt.show()
<pre name="code" class="plain">x = np.random.randn(1000)#生成随机数,均值0,方差1#np.random.rand() 生成0,1内均匀分布#常用:2.5 * np.random.randn(2,4) + 3y = np.random.randn(1000)plt.scatter(x,y)plt.title('Scatter')plt.show()

0 0
原创粉丝点击