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,在结构体定义,还有一些数组等 ...
随机推荐
- 《python源代码剖析》笔记 Python虚拟机框架
本文为senlie原创,转载请保留此地址:http://blog.csdn.net/zhengsenlie 1. Python虚拟机会从编译得到的PyCodeObject对象中依次读入每一条字节码指令 ...
- SQL LEN() 函数 ,case when,聚合函数的使用方法
SELECT aa.[User_Id],cc.[User_Name],dd.Name AS DepName,aa.Module_Id,aa.Module_Name, SUM(CASE aa.Opera ...
- Swift开发教程--怎样清除模拟器的数据
打开xcode->preference->location->derived Data,进入文件夹下,删除里面所以后的文件夹就能够了.
- light oj1074
Description The people of Mohammadpur have decided to paint each of their houses red, green, or blue ...
- 零基础学python-2.17 文件、open()、file()
今天我们来说说文件,以及跟文件有关的内建函数open和file 首先我们在python的根文件夹下建一个名为"123"的txt文本文件 文件中面我们输入一些文本 watermark ...
- ip地址转换成16进制long
<span style="font-size:18px;">public class IpUtil { /** * ip地址转换成16进制long * @param i ...
- 在Android中创建文件
import java.io.File; import java.io.IOException; import android.app.Activity; import android.os.Bund ...
- hihocoder 1676 树上等差数列 黑科技树形dp
#1676 : 树上的等差数列 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 给定一棵包含N个节点的无根树,节点编号1~N.其中每个节点都具有一个权值,第i个节点的权值 ...
- python 函数参数的传递(参数带星号的说明)
python中函数参数的传递是通过赋值来传递的.函数参数的使用又有俩个方面值得注意:1.函数参数是如何定义的 2.在调用函数的过程中参数是如何被解析 先看第一个问题,在python中函数参数的定义主要 ...
- HTML 14 JS事件
一 :什么是事件 发生的某一件事:触发特定的条件,完成某一项功能 二:学习的目的 在特定的条件下,完成特定的功能 条件满足的情况下,系统会自动执行 ( 回调 ) 绑定的方法 学习要点: 1.事件的两种 ...