matplotlib的annotate用法小结
这个是matplotlib自定义的annotate方法的文本:
一、
- def annotate(self, s, xy, *args, **kwargs):
- a = mtext.Annotation(s, xy, *args, **kwargs)
- a.set_transform(mtransforms.IdentityTransform())
- if 'clip_on' in kwargs:
- a.set_clip_path(self.patch)
- self._add_text(a)
- return a
这个方法里面定义了annotate方法所使用的变量,其中*args是tuple,**kwargs是dict
二、
- def __init__(self, s, xy,
- xytext=None,
- xycoords='data',
- textcoords=None,
- arrowprops=None,
- annotation_clip=None,
- **kwargs):
- """
- Annotate the point *xy* with text *s*.
- 在点xy:(x,y)处注释文本 s
- In the simplest form, the text is placed at *xy*.
- 在最简单的形式中,文本是处在xy的坐标点处
- Optionally, the text can be displayed in another position *xytext*.实际应用中,文本用xytext属性来随意定义文本所在的位置
- An arrow pointing from the text to the annotated point *xy* can then
- be added by defining *arrowprops*. 可以增加从文本到注释点xy的箭头指向,箭头样式通过arrowprops属性定义
- Parameters
- ----------
- s : str
- The text of the annotation.
- s:str类型,注释的文本
- xy : (float, float)
- The point *(x,y)* to annotate.
- xy: (float, float)坐标点,所要注释所在的坐标点
- xytext : (float, float), optional
- The position *(x,y)* to place the text at.
- If *None*, defaults to *xy*.
- xytext:(float, float)坐标点,可选,注释文本所在的坐标点,默认是上面xy的坐标点
- xycoords : str, `.Artist`, `.Transform`, callable or tuple, optional
- xycoords :str类型,Artist和Transform的matplotlib基类,元组,可选
- The coordinate system that *xy* is given in. The following types
- of values are supported:
- 给定的xy坐标系统是由属性xycoords来提供支持,该属性以下值
- - One of the following strings:
- ================= =============================================
- Value Description
- ================= =============================================
- 'figure points' Points from the lower left of the figure 距离图层左下角的点数量,比如xy=(10,10)说明距离图层左下方各10个点的位置
- 'figure pixels' Pixels from the lower left of the figure 距离图层左下角的像素,比如xy=(10,10)说明距离图层左下方各10个像素的位置
- 'figure fraction' Fraction of figure from lower left 距离图层左下角的数字分数,也就是百分比。左下角是(0,0),右上角是(1,1)。如果xy=(0.5,0.6),也就是距离左下角横坐标50%,纵坐标60%
- 'axes points' Points from lower left corner of axes 距离轴坐标左下角的点数量
- 'axes pixels' Pixels from lower left corner of axes 距离轴坐标左下角的像素
- 'axes fraction' Fraction of axes from lower left 距离轴坐标左下角的数字分数
- 'data' Use the coordinate system of the object being
- annotated (default) 使用实际的轴坐标的数据(默认)
- 'polar' *(theta,r)* if not native 'data' coordinates 使用极坐标系来处理,(弧度,长度)
- ================= =============================================
- - An `.Artist`: *xy* is interpreted as a fraction of the artists
- `~matplotlib.transforms.Bbox`. E.g. *(0, 0)* would be the lower
- left corner of the bounding box and *(0.5, 1)* would be the
- center top of the bounding box.
- - A `.Transform` to transform *xy* to screen coordinates.
- - A function with one of the following signatures::
- def transform(renderer) -> Bbox
- def transform(renderer) -> Transform
- where *renderer* is a `.RendererBase` subclass.
- The result of the function is interpreted like the `.Artist` and
- `.Transform` cases above.
- - A tuple *(xcoords, ycoords)* specifying separate coordinate
- systems for *x* and *y*. *xcoords* and *ycoords* must each be
- of one of the above described types.
- See :ref:`plotting-guide-annotation` for more details.
- Defaults to 'data'.
- textcoords : str, `.Artist`, `.Transform`, callable or tuple, optional
- The coordinate system that *xytext* is given in.
- textcoords :str类型,Artist和Transform的matplotlib基类,元组,可选,其值是与'xycoords'一致,并且也可以使用下面两个值《主要定义偏移量的》,如果没有说明,则与'xycoords'使用的坐标系统一致
- All *xycoords* values are valid as well as the following
- strings:
- ================= =========================================
- Value Description
- ================= =========================================
- 'offset points' Offset (in points) from the *xy* value
- 'offset pixels' Offset (in pixels) from the *xy* value
- ================= =========================================
- Defaults to the value of *xycoords*, i.e. use the same coordinate
- system for annotation point and text position.
- arrowprops : dict, optional
- The properties used to draw a
- `~matplotlib.patches.FancyArrowPatch` arrow between the
- positions *xy* and *xytext*.
- arrowprops : 字典类,可选。这个属性主要是用来画出xytext的文本坐标点到xy注释点坐标点的箭头指向线段
- If *arrowprops* does not contain the key 'arrowstyle' the
- allowed keys are:
- 如果arrowprops 字典类中不包含arrowstyle的key,则可以使用下列的KEY
- ========== ======================================================
- Key Description
- ========== ======================================================
- width The width of the arrow in points 宽度:以点为单位定义连线的宽度
- headwidth The width of the base of the arrow head in points 箭头宽度:以点为单位定义箭头的宽度
- headlength The length of the arrow head in points 箭头长度:以点为单位定义箭头的长度
- shrink Fraction of total length to shrink from both ends 缩小:移动提示,并使其离注释点和文本一些距离
- ? Any key to :class:`matplotlib.patches.FancyArrowPatch` 其他的matplotlib.patches.FancyArrowPatch基类中属性
- ========== ======================================================
- If *arrowprops* contains the key 'arrowstyle' the
- above keys are forbidden. The allowed values of
- ``'arrowstyle'`` are:
- 如果arrowprops 字典类中包含arrowstyle的key,则可以使用下列的赋值
- ============ =============================================
- 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
- ============ =============================================
- Valid keys for `~matplotlib.patches.FancyArrowPatch` are:
- =============== ==================================================
- Key Description
- =============== ==================================================
- arrowstyle the arrow style 箭头的样式
- connectionstyle the connection style 连接线的样式
- relpos default is (0.5, 0.5) 箭头起始点相对注释文本的位置,默认为 (0.5, 0.5),即文本的中心,
- (0,0)表示左下角,(1,1)表示右上角
- patchA default is bounding box of the text 箭头起点处的图形(matplotlib.patches对象),默认是注释文字框
- patchB default is None 箭头终点处的图形(matplotlib.patches对象),默认为空
- shrinkA default is 2 points 箭头起点的缩进点数,默认为2
- shrinkB default is 2 points 箭头终点的缩进点数,默认为2
- mutation_scale default is text size (in points)
- mutation_aspect default is 1.
- ? any key for :class:`matplotlib.patches.PathPatch` 其他matplotlib.patches.PathPatch的属性
- =============== ==================================================
- Defaults to None, i.e. no arrow is drawn. 默认是NONE,没有任何箭头绘制
- annotation_clip : bool or None, optional annotation_clip : 布尔值或者NONE,可选
- Whether to draw the annotation when the annotation point *xy* is 当注释点xy在子图区域外面是否要绘制注释
- outside the axes area.
- - If *True*, the annotation will only be drawn when *xy* is 设为True时,只有被注释点在子图区内时才绘制注释;
- within the axes.
- - If *False*, the annotation will always be drawn. 设为False时,无论被注释点在哪里都绘制注释。
- - If *None*, the annotation will only be drawn when *xy* is NONE:仅当xycoords为‘data’时,相当于True。
- within the axes and *xycoords* is 'data'.
- Defaults to *None*.
- **kwargs
- Additional kwargs are passed to `~matplotlib.text.Text`.
- Returns
- -------
- annotation : `.Annotation`
- See Also
- --------
- :ref:`plotting-guide-annotation`.
- """
- _AnnotationBase.__init__(self,
- xy,
- xycoords=xycoords,
- annotation_clip=annotation_clip)
- # warn about wonky input data
matplotlib的annotate用法小结的更多相关文章
- 转载:Hadoop排序工具用法小结
本文转载自Silhouette的文章,原文地址:http://www.dreamingfish123.info/?p=1102 Hadoop排序工具用法小结 发表于 2014 年 8 月 25 日 由 ...
- [No000010]Ruby 中一些百分号(%)的用法小结
#Ruby 中一些百分号(%)的用法小结 #这篇文章主要介绍了Ruby 中一些百分号(%)的用法小结,需要的朋友可以参考下 what_frank_said = "Hello!"#% ...
- C++ typedef用法小结 (※不能不看※)
C++ typedef用法小结 (※不能不看※) 第一.四个用途 用途一: 定义一种类型的别名,而不只是简单的宏替换.可以用作同时声明指针型的多个对象.比如:char* pa, pb; // 这多数不 ...
- 函数fgets和fputs、fread和fwrite、fscanf和fprintf用法小结 (转)
函数fgets和fputs.fread和fwrite.fscanf和fprintf用法小结 字符串读写函数fgets和fputs 一.读字符串函数fgets函数的功能是从指定的文件中读一个字符串到字符 ...
- 1:CSS中一些@规则的用法小结 2: @media用法详解
第一篇文章:@用法小结 第二篇文章:@media用法 第一篇文章:@用法小结 这篇文章主要介绍了CSS中一些@规则的用法小结,是CSS入门学习中的基础知识,需要的朋友可以参考下 at-rule ...
- 英语语法最终珍藏版笔记- 21it 用法小结
it 用法小结 it 在英语中的意思较多,用法较广,现总结如下. 一.it作句子的真正主语 1.it 指前面已经提到过的人或事物,有时指心目中的或成为问题的人或事物,作真正主语. 例如: What’s ...
- [转]ssh常用用法小结
ssh常用用法小结 1.连接到远程主机: 命令格式 : ssh name@remoteserver 或者 ssh remoteserver -l name 说明:以上两种方式都可以远程登录到远程主机, ...
- 结构体定义 typedef struct 用法详解和用法小结
typedef是类型定义的意思.typedef struct 是为了使用这个结构体方便.具体区别在于:若struct node {}这样来定义结构体的话.在申请node 的变量时,需要这样写,stru ...
- typedef用法小结
typedef用法小结- - 注意:本文转自网络,版权归原作者所有. typedef typedef用法小结- - 这两天在看程序的时候,发现很多地方都用到typedef,在结构体定义,还有一些数组等 ...
随机推荐
- 《解读window核心编程》 之 注冊表
1 注冊表的作用及组织形式 Windows系统使用注冊表来存储系统和应用程序配置数据.非常多系统和应用程序重要的配置的信息都存储在注冊表中. 注冊表是一种以树型结构组织的数据库.树的每个节点称 作键( ...
- Delphi7中的函数与过程(Function and Procedure)
1.锁住空间的位置,可以选择Edit--->Lock component ,也可以在窗体设计面板下面找到组件排版功能栏,第二排里面有个带锁的图标,表示组件可以被锁住.点击一下,组件的大小和位置就 ...
- 利用安卓手机搭建WEB服务器
背景介绍 Android是一种基于Linux的自由及开放源代码的操作系统 所以是用安卓来搭建服务器是完全可行的.接下来将教大家如何利用AndroPHP和Feel FTP(或者其他FTP管理器)来在安卓 ...
- ListView实现简单列表
ListView实现简单列表 效果图: 啥也没干的ListView张这样: fry.Activity01 package fry; import com.example.ListView.R; imp ...
- CockroachDB——类似spanner的开源版,底层使用rocksdb存储,mvcc,支持事务,raft一致性,licence是CockroachDB Community License Agreement
摘自:https://github.com/cockroachdb/cockroach/blob/master/docs/design.md CockroachDB is a distributed ...
- Python 2:str.title()(使字符串每个单词首字母大写)
name = "hello,world! hello,python!" print(name.title()) #单词首字母大写 运行结果将会是:Hello,World!Hello ...
- Django html页面 'ascii' codec can't encode characters in position 8-10: ordinal not
用Django开发的页面,之前用的是python3.X,后来又换成python2.X后各种报错,编码问题,于是在所有python文件开头加了编码:#coding=utf-8 但是后来发现,有些文件加了 ...
- jQuery考试之错题分析
获取元素范围大小顺序依次为: $(#one).siblings("div")>$("#one~div")>$("#one +div&quo ...
- 【转】SQL SERVER 主体,已同步
转自郭大侠博客: https://www.cnblogs.com/gered/p/10601202.html 目录 SQL SERVER 基于数据库镜像的主从同步... 1 1.概念... 2 1. ...
- KindEditor文本编辑框的实现
效果图: kindeditor 是一个插件 下载地址: https://files-cdn.cnblogs.com/files/lxnlxn/kindeditor.zip 解压后将其放在项目的js文件 ...