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字符串转为字典方法大全
方法一: 通过内置函数eval str_info = '{"name": "test", "age": 18}' dict_info = e ...
- 1+2+3+...+n不能用while、for、if else等实现
问题描写叙述 求 1+2+ - +n ,要求不能使用乘除法. for . while . if . else . switch . case 等keyword以及条件推断语句. 实际意义不大,题目涉及 ...
- Codeforces Round #250 Div. 2(C.The Child and Toy)
题目例如以下: C. The Child and Toy time limit per test 1 second memory limit per test 256 megabytes input ...
- 飘逸的python - 极简的二叉树前中后序通杀函数
对于任一结点.能够按某种次序运行三个操作: 訪问结点本身(N) 遍历该结点的左子树(L) 遍历该结点的右子树(R) 用来表示顺序,即,前序NLR/中序LNR/后序LRN. 以下我们用namedtupl ...
- 5分钟快速构建苹果IPA免费发布服务器
在ios的开发中, 通过苹果的各种秘钥加密, 我们会生成一个.ipa文件,这就是我们的应用软件的安装包. 这个文件是能被安装到iphone/ipad上的.可是,如何才能让不在身边的人安装上这个应用呢? ...
- Get-Acl 查看文件权限
https://blogs.msmvps.com/erikr/2007/09/26/set-permissions-on-a-specific-service-windows/ Get-Acl .\L ...
- (Go)10.流程控制示例
package main import ( "math/rand" "fmt" ) func main() { //var n int n := rand.In ...
- P1966 火柴排队(逆序对)
P1966 火柴排队 题目描述 涵涵有两盒火柴,每盒装有 n 根火柴,每根火柴都有一个高度. 现在将每盒中的火柴各自排成一列, 同一列火柴的高度互不相同, 两列火柴之间的距离定义为: ∑(ai-bi) ...
- [Apple开发者帐户帮助]六、配置应用服务(1.1)Apple Pay:配置Apple Pay(iOS,watchOS)
Apple Pay允许用户在您的应用中购买商品和服务.要将Apple Pay 权利添加到您的App ID,请先创建商家标识符,然后启用Apple Pay并创建付款处理证书. 或者,您可以使用Xcode ...
- selenium3 + python3 - alert定位
一.alert\confirm\prompt弹出框操作主要方法有: text:获取文本值 accept() :点击"确认" dismiss() :点击"取消"或 ...