python numpy 包积累

2017.11.4

np.ptp(array)#最大值和最小值之间的差值,peak to peak

np.array(data).flatten()#展平数据,http://www.cnblogs.com/itdyb/p/5796834.html

np.ones(N, dtype=np.bool)

http://www.mamicode.com/info-detail-992832.html

 2017.11.5

1.np.linspace(startstopnum=50)#生成指定区间下指定区间个数的区间的两端,Return evenly spaced numbers over a specified interval.

  np.linspace(5,10,3)#http://blog.csdn.net/grey_csdn/article/details/54561796;https://docs.scipy.org/doc/numpy/reference/generated/numpy.linspace.html

  Out[71]: array([ 5. , 7.5, 10. ])

2.np.meshgrid(x,y)#生成网格点,转载自http://www.cnblogs.com/sunshinewang/p/6897966.html

  #其主要作用是用于绘制形如x**2+y**2的函数图形,先为x变化,y不发生变化,例如咋x=-2,-1,0,1时y=1;然后依次进行下去

  #一般会使用plt.imshow()进行画图,横         纵坐标为数据的索引,颜色为值http://blog.csdn.net/shuke1991/article/details/50462580

  x = np.arange(-2,2); y = np.arange(0,3)

      z,s = np.meshgrid(x,y)

  z  

  array([[-2, -1, 0, 1],
  [-2, -1, 0, 1],
  [-2, -1, 0, 1]])

  s  

  array([[0, 0, 0, 0],
  [1, 1, 1, 1],
  [2, 2, 2, 2]])

  plt.scatter(z,s)#如下图所示

 

posted on 2017-11-04 10:38  湘雨jay  阅读(162)  评论(0编辑  收藏  举报