matplotlib.pyplot 标记出曲线上最大点和最小点的位置
2016-08-04 15:03
5317 查看
废话不多说,直接上代码。
要求:正确安装了matplotlib库
效果图如下:
要求:正确安装了matplotlib库
import matplotlib.pyplot as plt import numpy as np def demo_test(): a=np.array([0.15,0.16,0.14,0.17,0.12,0.16,0.1,0.08,0.05,0.07,0.06]); max_indx=np.argmax(a)#max value index min_indx=np.argmin(a)#min value index plt.plot(a,'r-o') plt.plot(max_indx,a[max_indx],'ks') show_max='['+str(max_indx)+' '+str(a[max_indx])+']' plt.annotate(show_max,xytext=(max_indx,a[max_indx]),xy=(max_indx,a[max_indx])) plt.plot(min_indx,a[min_indx],'gs') plt.show() if __name__=="__main__": demo_test();
效果图如下:
相关文章推荐
- 利用Python和OpenCV库将URL转换为OpenCV格式的方法
- Python NumPy库安装使用笔记
- Python中的Numpy入门教程
- #numpy#关于数组形状
- Python 排列组合以及多维数组排序
- NumPy基础(一)
- 安装numpy matplotlib
- python+numpy+scipy=matlab,抛弃matlab
- Python安装matplotlib所需要的软件以及问题的解决方法
- 例2.1.1的Numpy实现
- matplotlib初试——求两条直线相交的大概位置
- 绘制弹性模量的变化
- theano学习札记
- ParaView - Mixing NumPy and VTK APIs with high efficient using Python Programmable filter
- 开始正式写博客的第一天
- 新手学NumPy
- 创建视图和副本
- 来自bit.ly的1.usa.gov数据
- numba版 自适应差分进化算法 速度超快 可以求解约束问题
- windows下安装Python以及numpy、scipy、scitik-learn模块(3.4版本)