python 的 matplotlib
2017-12-04 09:39
253 查看
本文会一直更新matplot的画图技巧,使用方法
matplotlib教程
matplotlib API
结果
结果
tip-颜色和线形可随意搭配。 ‘b^’ 或‘g>’或 ”bo”
matplotlib教程
matplotlib API
1、实例一
本实例展示了matplotlib画图的基本流程import matplotlib.pyplot as plt # step 1 prepare data x = [1,2,3,4] y = [10,20,25,30] # step 2 create plot fig = plt.figure() # step 3 plot settings ax = 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 imshow plt.show() # if you want to save plt.savefig('foo.png')
结果
2、实例二
# -*- coding: utf-8 -*- import numpy as np import matplotlib .pyplot as plt from scipy import interpolate from scipy import optimize x = [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、颜色
character | color |
---|---|
‘b’ | blue |
‘g’ | green |
‘r’ | red |
‘c’ | cyan |
‘m’ | magenta |
‘y’ | yellow |
‘k’ | black |
‘w’ | white |
2、线形
character | description |
---|---|
‘-‘ | solid line style |
‘–’ | dashed line style |
‘-.’ | dash-dot line style |
‘:’ | dotted line style |
‘.’ | point marker |
‘,’ | pixel marker |
‘o’ | circle marker |
‘v’ | triangle_down marker |
‘^’ | triangle_up marker |
‘<’ | triangle_left marker |
’s’ | square marker |
‘p’ | pentagon marker |
‘x’ | x marker |
‘D’ | diamond marker |
‘_’ | hline marker |
3.1.2 x 轴显示
rotation=30, 可以用于x轴的标注3.2
小写希腊字母相关文章推荐
- Python matplotlib支持中文
- Windows下python安装matplotlib
- Python matplotlib 画图窗口显示到gui或者控制台的方法
- Python matplotlib笔记
- python数据挖掘课程 十.Pandas、Matplotlib、PCA绘图实用代码补充
- Python 安装matplotlib,six,dateutil,pyparsing 完整过程
- 【python】pandas & matplotlib 数据处理 绘制曲面图
- python(numpy scipy matplotlib sklearn)安装
- window环境下python安装numpy、scipy、matplotlib等科学计算包
- matplotlib数据可视化入门-python
- Python笔记-NumPy,SciPy,IPython,Matplotlib
- Python--matplotlib绘图可视化知识点整理
- Python使用matplotlib绘制三维曲线
- 如何在Linux系统Ubuntu版本下安装Python开发包NumPy、Matplotlib、SciPy
- python:matplotlib及pandas绘图(2)
- Python: matplotlib模块 源码阅读&理解
- python Matplotlib 模块
- python使用matplotlib绘图 -- barChart
- Windows10+Python3下安装NumPy+SciPy+Matplotlib
- win7 64位系统 python 2 安装 scipy, matplotlib