python 的 matplotlib
来源:互联网 发布:java教育 编辑:程序博客网 时间:2024/06/03 17:28
本文会一直更新matplot的画图技巧,使用方法
matplotlib教程
matplotlib API
1、实例一
本实例展示了matplotlib画图的基本流程
import matplotlib.pyplot as plt# step 1 prepare datax = [1,2,3,4]y = [10,20,25,30]# step 2 create plotfig = plt.figure()# step 3 plot settingsax = fig.add_subplot(2,2,1)ax.plot(x, y, color='blue', linewidth=2)ax.set_xlim(1,6.5)bx = fig.add_subplot(2,1,2)bx.scatter([2,4,6,5], [3,7,20,4], color = 'green', marker= '*')# step 4 plot imshowplt.show()# if you want to saveplt.savefig('foo.png')
结果
2、实例二
# -*- coding: utf-8 -*-import numpy as npimport matplotlib .pyplot as pltfrom scipy import interpolatefrom scipy import optimizex = [0.01, 0.05, 0.08 , 0.1 ,0.2,0.4, 0.8, 1, 1.24,1.53,2]y = [97.723, 97.456, 98.346, 99.124, 99.234, 98.5,98.43, 97.71,97.4, 97.24,97.20]x1 = [0.01, 0.08 , 0.1 ,0.2,0.4, 1, 1.24,1.53,2]y1 = [97.723, 98.346, 99.124, 99.234, 98.5, 97.71,97.4, 97.24,97.20]t1 = [0.05, 97.456]t2 = [0.8, 98.43]fig = plt.figure()img = fig.add_subplot(111)img.plot(x,y,color="blue",linewidth=1)img.plot(x1,y1,'k^')xnew = np.linspace(min(x),max(x),300)f2 = interpolate.interp1d(x,y,kind=2)plt.plot(xnew, f2(xnew),'-.',color="green")img.set_title("the sensitiveness of hyper parameter $\lambda$",size=14)#r'$\lambda$'img.set_xlabel('$\lambda$' + '- type:float',size=12)img.set_ylabel('Verfication on LFW Accuracy(%)',size=12)img.set_ylim(96,100)plt.grid(True)plt.scatter([t1[0],],[t1[1],], 30, color='red')plt.scatter([t2[0],],[t2[1],], 30, color='red')plt.annotate(r'A(0.05, 97.456)', t1, xycoords='data', xytext=(-15,-30), textcoords='offset points', fontsize=12, arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=.2"))plt.annotate(r'B(0.8, 98.43)', t2, xycoords='data', xytext=(+40,+40), textcoords='offset points', fontsize=12, arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=.2"))plt.legend(['Linear','data','cubic smooth','key point'],loc='lower right',ncol=2)plt.show()
结果
3、一些查表的参数
3.1.1 颜色& 线形
1、颜色
2、线形
tip-颜色和线形可随意搭配。 ‘b^’ 或‘g>’或 ”bo”
3.1.2 x 轴显示
rotation=30, 可以用于x轴的标注
3.2
小写希腊字母
阅读全文
0 0
- python Matplotlib的安装
- python matplotlib的安装
- python matplotlib的使用
- python的matplotlib使用
- python 的 matplotlib
- python的画图模块matplotlib
- python matplotlib 方程的绘制
- 用python的matplotlib画图
- python的制表工具包Matplotlib
- python 中matplotlib的使用
- [python]matplotlib的快速学习
- python matplotlib图像的绘制
- Python的matplotlib(2)
- python matplotlib
- Python-Matplotlib
- Python matplotlib
- python-matplotlib
- python-matplotlib
- 【Scikit-Learn 中文文档】神经网络模型(无监督)- 无监督学习
- Day014
- 以ajax方式向后台发送文件
- 送花
- 开发中Chrome常用插件和应用
- python 的 matplotlib
- JQuery Easy Ui dataGrid 数据表格 此文章解决easy ui 足矣
- jdbc批处理
- 算法——跳跃搜索
- 【Scikit-Learn 中文文档】交叉验证
- First Blog
- Two Sum[LeetCode 1]
- surfacelinger学习计划
- 浏览器搜索规则