1、plt.subplot()

import matplotlib.pyplot as plt# Integer subplot specification must be a three digit number
# 前两位代表横竖长度比
# 左边的代表横,中间的代标纵坐标,右边的则表示绘图位置(当横纵比不是1:1时)
ax1, ax2, ax3 = plt.subplot(231), plt.subplot(232), plt.subplot(233)
ax4, ax5, ax6 = plt.subplot(234), plt.subplot(235), plt.subplot(236)
# 被注释的地方xy(x, y)和插入文本的地方xytext(x, y)
ax2.annotate("Test", xy=(0.5, 0.5), xycoords=ax1.transData,xytext=(0.5, 0.5), textcoords=ax2.transData,arrowprops=dict(arrowstyle="<-"))
ax3.annotate("ax3", xy=(0.5, 0.5), xytext=(0.5, 0.5))
ax4.annotate("ax4", xy=(0.5, 0.5), xytext=(0.5, 0.5))
ax5.annotate("ax5", xy=(0.5, 0.5), xytext=(0.5, 0.5))
ax6.annotate("ax6", xy=(0.5, 0.5), xytext=(0.5, 0.5))
plt.show()

2、annotate

  • 被注释的地方xy(x, y)和插入文本的地方xytext(x, y)
  • xycoords和textcoords指定xy和xytext的坐标系。默认为data(使用轴域数据坐标系)

| 参数 | 坐标系 |

'figure points'  | 距离图形左下角的点数量 | 
'figure pixels'  | 距离图形左下角的像素数量 | 
'figure fraction'  | 0,0 是图形左下角,1,1 是右上角 | 
'axes points'  | 距离轴域左下角的点数量 | 
'axes pixels'  | 距离轴域左下角的像素数量 | 
'axes fraction'  | 0,0 是轴域左下角,1,1 是右上角 |

'data' | 使用轴域数据坐标系 |

import matplotlib.pyplot as plt
from numpy import *ax1 = plt.subplot(111)t = arange(0.0, 5.0, 0.01)
s = cos(2*pi*t)
line = plt.plot(t, s, lw=2)
# 被注释的地方xy(x, y)和插入文本的地方xytext(x, y)
# xycoords和textcoords指定xy和xytext的坐标系。默认为data(使用轴域数据坐标系)ax1.annotate('local max', xy=(2, 1), xytext=(3, 1.5),arrowprops=dict(facecolor='black'))plt.ylim(-2, 2)
plt.show()

3、在机器学习实战的第三章,我们还用到了箭头(arrow)和文本框(box)

import matplotlib.pyplot as plt# boxstyle文本框样式, fc(face color)背景透明度
decisionNode = dict(boxstyle="round4, pad=0.5", fc="0.8")
leafNode = dict(boxstyle="circle", fc="0.8")
# 箭头样式
arrow_args = dict(arrowstyle="<-")def plotNode(nodeTxt, centerPt, parentPt, nodeType):createPlot.ax1.annotate(nodeTxt, xy=parentPt, xycoords="axes fraction",xytext=centerPt, textcoords="axes fraction", va="center",ha="center", bbox=nodeType, arrowprops=arrow_args)def createPlot():fig = plt.figure(1, facecolor="white")fig.clf()createPlot.ax1 = plt.subplot(111, frameon=False)plotNode('决策点', (0.5, 0.1), (0.1, 0.5), decisionNode)plotNode('叶节点', (0.8, 0.1), (0.3, 0.8), leafNode)# plt.rcParams['font.sans-serif'] = ['SimHei']plt.show()createPlot()
  • Annotating with Text with Box:boxstyle

Class

Name

Attrs

Circle

circle

pad=0.3

DArrow

darrow

pad=0.3

LArrow

larrow

pad=0.3

RArrow

rarrow

pad=0.3

Round

round

pad=0.3,rounding_size=None

Round4

round4

pad=0.3,rounding_size=None

Roundtooth

roundtooth

pad=0.3,tooth_size=None

Sawtooth

sawtooth

pad=0.3,tooth_size=None

Square

square

pad=0.3

  • Annotating with Arrow:arrowstyle

Name

Attrs

-

None

->

head_length=0.4,head_width=0.2

-[

widthB=1.0,lengthB=0.2,angleB=None

|-|

widthA=1.0,widthB=1.0

-|>

head_length=0.4,head_width=0.2

<-

head_length=0.4,head_width=0.2

<->

head_length=0.4,head_width=0.2

<|-

head_length=0.4,head_width=0.2

<|-|>

head_length=0.4,head_width=0.2

fancy

head_length=0.4,head_width=0.4,tail_width=0.4

simple

head_length=0.5,head_width=0.5,tail_width=0.2

wedge

tail_width=0.3,shrink_factor=0.5

小试牛刀Matplotlib相关推荐

  1. Python数据分析入门(一)——初探数据可视化

    前言 静下心算算,当程序员已经有好几年了,不过自大学时代开始,学习对我来说就是个被动接受的过程,学校的课程.当时热门的移动端开发.数据库的学习.web学习.PHP后端学习--需要做什么我便去学什么,到 ...

  2. 老咸鱼今天告诉你用Python matplotlib 各种图绘制流线图,难怪老板放纵他

    复习回顾 在Python关于绘图,Mlab提供开源的matplotlib模块,不仅可以绘制折线图.柱状图.散点图等常规图外,还支持绘制量场图.频谱图.提琴图.箱型图等特殊图,例举往期文章可前往查看详情 ...

  3. Python matplotlib 绘制量场图

    复习回顾 matplotlib 是基于Python语言的开源项目,pyplot提供一系列绘制2D图形的方法.随着版本的迭代,matplotlib 模块也支持绘制3D图形mplot3d工具包,制作动态图 ...

  4. 不愧是摸鱼高手Python matplotlib 绘制频谱图都会,能怪老板不管

    复习回顾 matplotlib 是Python专门用来绘制渲染的模块,其底层主要分为脚本层.美工层和后端.脚本层为我们提供常见图形绘制如折线.柱状.直方.饼图.以往文章 这么详细的Python mat ...

  5. 超详细的Python matplotlib 绘制动态图

    复习回顾 在matplotlib模块中我们前面学习绘制如折线.柱状.散点.直方图等静态图形.我们都知道在matplotlib模块主要有三层脚本层为用户提供快捷的绘制图形方法,美工层接收到脚本层的命令后 ...

  6. 这么详细的Python matplotlib 绘制图形 还不赶紧收藏

    前言 我们前面对matplotlib模块底层结构学习,对其pyplot类(脚本层)类提供的绘制折线图.柱状图.饼图.直方图等统计图表的相关方法,列举往期文章如下. 超详细的Python matplot ...

  7. 【数据分析可视化】各国商店-小试牛刀

    分组+plt 各国商店-小试牛刀 # 基本信息 import numpy as np import pandas as pd from pandas import Series, DataFrame# ...

  8. matplotlib交互模式

    Matpotlib交互模式 在运行python程序时有时候需要生成以下的 动态图模式 来显示程序运行的结果 此时需要使用matplotlib的 交互模式 ,在Ipython中时默认使用交互模式的. 在 ...

  9. matplotlib绘制热力图

    版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/jin_tmac/article/det ...

最新文章

  1. 使用canvas绘制圆形进度条
  2. 拉格朗日差值法----算法学习
  3. android arm
  4. Python基础day03【字符串(定义、输入输出、常用方法)、列表(定义、基本使用、增删改查、嵌套)、元组】
  5. 华为上机考试题系列(一):牛客网的奇葩操作
  6. R语言学习2-RMarkdown入门使用
  7. thinkpad linux 键盘,Linux 5.10或支持联想PC键盘快捷键
  8. 形位公差符号大全_干货!AutoCAD快捷键大全与功能精解
  9. spring Annotation 组件注入
  10. Python判断字符类型
  11. 火狐插件 xpi打包_将Firefox扩展程序打包为XPI
  12. 注意力机制在视觉中的实战
  13. 【整理】C#中GridView隐藏指定列的方法
  14. 抖音新手常犯的几个雷区,你知道几个?
  15. 初中学历可以学软件测试转行吗
  16. mmo手游地图同步总结
  17. 3分钟打动客户:电话销售实战技能训练
  18. 电商API_拼多多商品详细
  19. 添加本地jar包到maven仓库报401和405错误
  20. 深度剖析E680G开发四.移植OPIE操作系统(中)-交叉编译Qte

热门文章

  1. 活动 | 玩转“视”界杯 —— 2018 上半年广告数据分析及短视频分享
  2. bootstrap checkbox选中事件
  3. 几款xshell绝佳配色方案
  4. Cocos Creator JS 时间戳日期转换
  5. springboot添加swagger2组件
  6. lazy ideas in programming(编程中的惰性思想)
  7. [链接]C++和Python版本的委托
  8. Fully decentralized NFT system towards Metaverse: Next generation Seatlab business model
  9. Girton events
  10. UNITY 模型与动画优化选项