这个是matplotlib自定义的annotate方法的文本:

一、

  1. def annotate(self, s, xy, *args, **kwargs):
  2. a = mtext.Annotation(s, xy, *args, **kwargs)
  3. a.set_transform(mtransforms.IdentityTransform())
  4. if 'clip_on' in kwargs:
  5. a.set_clip_path(self.patch)
  6. self._add_text(a)
  7. return a

这个方法里面定义了annotate方法所使用的变量,其中*args是tuple,**kwargs是dict

二、

  1. def __init__(self, s, xy,
  2. xytext=None,
  3. xycoords='data',
  4. textcoords=None,
  5. arrowprops=None,
  6. annotation_clip=None,
  7. **kwargs):
  8. """
  9. Annotate the point *xy* with text *s*.
  10. 在点xy:(x,y)处注释文本 s
  11. In the simplest form, the text is placed at *xy*.
  12. 在最简单的形式中,文本是处在xy的坐标点处
  13. Optionally, the text can be displayed in another position *xytext*.实际应用中,文本用xytext属性来随意定义文本所在的位置
  14. An arrow pointing from the text to the annotated point *xy* can then
  15. be added by defining *arrowprops*. 可以增加从文本到注释点xy的箭头指向,箭头样式通过arrowprops属性定义
  16.  
  17. Parameters
  18. ----------
  19. s : str
  20. The text of the annotation.
  21. s:str类型,注释的文本
  22. xy : (float, float)
  23. The point *(x,y)* to annotate.
  24. xy: (float, float)坐标点,所要注释所在的坐标点
  25. xytext : (float, float), optional
  26. The position *(x,y)* to place the text at.
  27. If *None*, defaults to *xy*.
  28. xytext:(float, float)坐标点,可选,注释文本所在的坐标点,默认是上面xy的坐标点
  29. xycoords : str, `.Artist`, `.Transform`, callable or tuple, optional
  30. xycoords :str类型,Artist和Transform的matplotlib基类,元组,可选
  31. The coordinate system that *xy* is given in. The following types
  32. of values are supported:
  33. 给定的xy坐标系统是由属性xycoords来提供支持,该属性以下值
  34. - One of the following strings:
  35.  
  36. ================= =============================================
  37. Value Description
  38. ================= =============================================
  39. 'figure points' Points from the lower left of the figure 距离图层左下角的点数量,比如xy=(10,10)说明距离图层左下方各10个点的位置
  40. 'figure pixels' Pixels from the lower left of the figure 距离图层左下角的像素,比如xy=(10,10)说明距离图层左下方各10个像素的位置
  41. 'figure fraction' Fraction of figure from lower left 距离图层左下角的数字分数,也就是百分比。左下角是(0,0),右上角是(1,1)。如果xy=(0.5,0.6),也就是距离左下角横坐标50%,纵坐标60%
  42. 'axes points' Points from lower left corner of axes 距离轴坐标左下角的点数量
  43. 'axes pixels' Pixels from lower left corner of axes 距离轴坐标左下角的像素
  44. 'axes fraction' Fraction of axes from lower left 距离轴坐标左下角的数字分数
  45. 'data' Use the coordinate system of the object being
  46. annotated (default) 使用实际的轴坐标的数据(默认)
  47. 'polar' *(theta,r)* if not native 'data' coordinates 使用极坐标系来处理,(弧度,长度)
  48. ================= =============================================
  49.  
  50. - An `.Artist`: *xy* is interpreted as a fraction of the artists
  51. `~matplotlib.transforms.Bbox`. E.g. *(0, 0)* would be the lower
  52. left corner of the bounding box and *(0.5, 1)* would be the
  53. center top of the bounding box.
  54.  
  55. - A `.Transform` to transform *xy* to screen coordinates.
  56.  
  57. - A function with one of the following signatures::
  58.  
  59. def transform(renderer) -> Bbox
  60. def transform(renderer) -> Transform
  61.  
  62. where *renderer* is a `.RendererBase` subclass.
  63.  
  64. The result of the function is interpreted like the `.Artist` and
  65. `.Transform` cases above.
  66.  
  67. - A tuple *(xcoords, ycoords)* specifying separate coordinate
  68. systems for *x* and *y*. *xcoords* and *ycoords* must each be
  69. of one of the above described types.
  70.  
  71. See :ref:`plotting-guide-annotation` for more details.
  72.  
  73. Defaults to 'data'.
  74.  
  75. textcoords : str, `.Artist`, `.Transform`, callable or tuple, optional
  76. The coordinate system that *xytext* is given in.
  77. textcoords :str类型,Artist和Transform的matplotlib基类,元组,可选,其值是与'xycoords'一致,并且也可以使用下面两个值《主要定义偏移量的》,如果没有说明,则与'xycoords'使用的坐标系统一致
  78. All *xycoords* values are valid as well as the following
  79. strings:
  80.  
  81. ================= =========================================
  82. Value Description
  83. ================= =========================================
  84. 'offset points' Offset (in points) from the *xy* value
  85. 'offset pixels' Offset (in pixels) from the *xy* value
  86. ================= =========================================
  87.  
  88. Defaults to the value of *xycoords*, i.e. use the same coordinate
  89. system for annotation point and text position.
  90.  
  91. arrowprops : dict, optional
  92. The properties used to draw a
  93. `~matplotlib.patches.FancyArrowPatch` arrow between the
  94. positions *xy* and *xytext*.
  95. arrowprops : 字典类,可选。这个属性主要是用来画出xytext的文本坐标点到xy注释点坐标点的箭头指向线段
  96. If *arrowprops* does not contain the key 'arrowstyle' the
  97. allowed keys are:
  98. 如果arrowprops 字典类中不包含arrowstyle的key,则可以使用下列的KEY
  99. ========== ======================================================
  100. Key Description
  101. ========== ======================================================
  102. width The width of the arrow in points 宽度:以点为单位定义连线的宽度
  103. headwidth The width of the base of the arrow head in points 箭头宽度:以点为单位定义箭头的宽度
  104. headlength The length of the arrow head in points 箭头长度:以点为单位定义箭头的长度
  105. shrink Fraction of total length to shrink from both ends 缩小:移动提示,并使其离注释点和文本一些距离
  106. ? Any key to :class:`matplotlib.patches.FancyArrowPatch` 其他的matplotlib.patches.FancyArrowPatch基类中属性
  107. ========== ======================================================
  108.  
  109. If *arrowprops* contains the key 'arrowstyle' the
  110. above keys are forbidden. The allowed values of
  111. ``'arrowstyle'`` are:
  112. 如果arrowprops 字典类中包含arrowstyle的key,则可以使用下列的赋值
  113. ============ =============================================
  114. Name Attrs
  115. ============ =============================================
  116. ``'-'`` None
  117. ``'->'`` head_length=0.4,head_width=0.2
  118. ``'-['`` widthB=1.0,lengthB=0.2,angleB=None
  119. ``'|-|'`` widthA=1.0,widthB=1.0
  120. ``'-|>'`` head_length=0.4,head_width=0.2
  121. ``'<-'`` head_length=0.4,head_width=0.2
  122. ``'<->'`` head_length=0.4,head_width=0.2
  123. ``'<|-'`` head_length=0.4,head_width=0.2
  124. ``'<|-|>'`` head_length=0.4,head_width=0.2
  125. ``'fancy'`` head_length=0.4,head_width=0.4,tail_width=0.4
  126. ``'simple'`` head_length=0.5,head_width=0.5,tail_width=0.2
  127. ``'wedge'`` tail_width=0.3,shrink_factor=0.5
  128. ============ =============================================
  129.  
  130. Valid keys for `~matplotlib.patches.FancyArrowPatch` are:
  131.  
  132. =============== ==================================================
  133. Key Description
  134. =============== ==================================================
  135. arrowstyle the arrow style 箭头的样式
  136. connectionstyle the connection style 连接线的样式
  137. relpos default is (0.5, 0.5) 箭头起始点相对注释文本的位置,默认为 (0.5, 0.5),即文本的中心,
  138. (0,0)表示左下角,(1,1)表示右上角
  139. patchA default is bounding box of the text 箭头起点处的图形(matplotlib.patches对象),默认是注释文字框
  140. patchB default is None 箭头终点处的图形(matplotlib.patches对象),默认为空
  141. shrinkA default is 2 points 箭头起点的缩进点数,默认为2
  142. shrinkB default is 2 points 箭头终点的缩进点数,默认为2
  143. mutation_scale default is text size (in points)
  144. mutation_aspect default is 1.
  145. ? any key for :class:`matplotlib.patches.PathPatch` 其他matplotlib.patches.PathPatch的属性
  146. =============== ==================================================
  147.  
  148. Defaults to None, i.e. no arrow is drawn. 默认是NONE,没有任何箭头绘制
  149.  
  150. annotation_clip : bool or None, optional annotation_clip : 布尔值或者NONE,可选
  151. Whether to draw the annotation when the annotation point *xy* is 当注释点xy在子图区域外面是否要绘制注释
  152. outside the axes area.
  153.  
  154. - If *True*, the annotation will only be drawn when *xy* is 设为True时,只有被注释点在子图区内时才绘制注释;
  155. within the axes.
  156. - If *False*, the annotation will always be drawn. 设为False时,无论被注释点在哪里都绘制注释。
  157. - If *None*, the annotation will only be drawn when *xy* is NONE:仅当xycoords为‘data’时,相当于True。
  158. within the axes and *xycoords* is 'data'.
  159.  
  160. Defaults to *None*.
  161.  
  162. **kwargs
  163. Additional kwargs are passed to `~matplotlib.text.Text`.
  164.  
  165. Returns
  166. -------
  167. annotation : `.Annotation`
  168.  
  169. See Also
  170. --------
  171. :ref:`plotting-guide-annotation`.
  172.  
  173. """
  174. _AnnotationBase.__init__(self,
  175. xy,
  176. xycoords=xycoords,
  177. annotation_clip=annotation_clip)
  178. # warn about wonky input data

  

matplotlib的annotate用法小结的更多相关文章

  1. 转载:Hadoop排序工具用法小结

    本文转载自Silhouette的文章,原文地址:http://www.dreamingfish123.info/?p=1102 Hadoop排序工具用法小结 发表于 2014 年 8 月 25 日 由 ...

  2. [No000010]Ruby 中一些百分号(%)的用法小结

    #Ruby 中一些百分号(%)的用法小结 #这篇文章主要介绍了Ruby 中一些百分号(%)的用法小结,需要的朋友可以参考下 what_frank_said = "Hello!"#% ...

  3. C++ typedef用法小结 (※不能不看※)

    C++ typedef用法小结 (※不能不看※) 第一.四个用途 用途一: 定义一种类型的别名,而不只是简单的宏替换.可以用作同时声明指针型的多个对象.比如:char* pa, pb; // 这多数不 ...

  4. 函数fgets和fputs、fread和fwrite、fscanf和fprintf用法小结 (转)

    函数fgets和fputs.fread和fwrite.fscanf和fprintf用法小结 字符串读写函数fgets和fputs 一.读字符串函数fgets函数的功能是从指定的文件中读一个字符串到字符 ...

  5. 1:CSS中一些@规则的用法小结 2: @media用法详解

    第一篇文章:@用法小结 第二篇文章:@media用法 第一篇文章:@用法小结 这篇文章主要介绍了CSS中一些@规则的用法小结,是CSS入门学习中的基础知识,需要的朋友可以参考下     at-rule ...

  6. 英语语法最终珍藏版笔记- 21it 用法小结

    it 用法小结 it 在英语中的意思较多,用法较广,现总结如下. 一.it作句子的真正主语 1.it 指前面已经提到过的人或事物,有时指心目中的或成为问题的人或事物,作真正主语. 例如: What’s ...

  7. [转]ssh常用用法小结

    ssh常用用法小结 1.连接到远程主机: 命令格式 : ssh name@remoteserver 或者 ssh remoteserver -l name 说明:以上两种方式都可以远程登录到远程主机, ...

  8. 结构体定义 typedef struct 用法详解和用法小结

    typedef是类型定义的意思.typedef struct 是为了使用这个结构体方便.具体区别在于:若struct node {}这样来定义结构体的话.在申请node 的变量时,需要这样写,stru ...

  9. typedef用法小结

    typedef用法小结- - 注意:本文转自网络,版权归原作者所有. typedef typedef用法小结- - 这两天在看程序的时候,发现很多地方都用到typedef,在结构体定义,还有一些数组等 ...

随机推荐

  1. 《解读window核心编程》 之 注冊表

    1 注冊表的作用及组织形式 Windows系统使用注冊表来存储系统和应用程序配置数据.非常多系统和应用程序重要的配置的信息都存储在注冊表中. 注冊表是一种以树型结构组织的数据库.树的每个节点称 作键( ...

  2. Delphi7中的函数与过程(Function and Procedure)

    1.锁住空间的位置,可以选择Edit--->Lock component ,也可以在窗体设计面板下面找到组件排版功能栏,第二排里面有个带锁的图标,表示组件可以被锁住.点击一下,组件的大小和位置就 ...

  3. 利用安卓手机搭建WEB服务器

    背景介绍 Android是一种基于Linux的自由及开放源代码的操作系统 所以是用安卓来搭建服务器是完全可行的.接下来将教大家如何利用AndroPHP和Feel FTP(或者其他FTP管理器)来在安卓 ...

  4. ListView实现简单列表

    ListView实现简单列表 效果图: 啥也没干的ListView张这样: fry.Activity01 package fry; import com.example.ListView.R; imp ...

  5. CockroachDB——类似spanner的开源版,底层使用rocksdb存储,mvcc,支持事务,raft一致性,licence是CockroachDB Community License Agreement

    摘自:https://github.com/cockroachdb/cockroach/blob/master/docs/design.md CockroachDB is a distributed ...

  6. Python 2:str.title()(使字符串每个单词首字母大写)

    name = "hello,world! hello,python!" print(name.title()) #单词首字母大写 运行结果将会是:Hello,World!Hello ...

  7. Django html页面 'ascii' codec can't encode characters in position 8-10: ordinal not

    用Django开发的页面,之前用的是python3.X,后来又换成python2.X后各种报错,编码问题,于是在所有python文件开头加了编码:#coding=utf-8 但是后来发现,有些文件加了 ...

  8. jQuery考试之错题分析

    获取元素范围大小顺序依次为: $(#one).siblings("div")>$("#one~div")>$("#one +div&quo ...

  9. 【转】SQL SERVER 主体,已同步

    转自郭大侠博客:  https://www.cnblogs.com/gered/p/10601202.html 目录 SQL SERVER 基于数据库镜像的主从同步... 1 1.概念... 2 1. ...

  10. KindEditor文本编辑框的实现

    效果图: kindeditor 是一个插件 下载地址: https://files-cdn.cnblogs.com/files/lxnlxn/kindeditor.zip 解压后将其放在项目的js文件 ...