a. Line2D类

    1. 这些关键字参数都是Line2D的属性。其属性有:

    • 继承自Artist基类的属性: .alpha.animated.axes.clip_box、..clip_on.clip_path.contains.figure.gid.label.picker.transform.url.visible.zorder

    • .antialiased或者.aa属性:一个布尔值。如果为True则表示线条是抗锯齿处理的

    • .color或者.c属性:一个matplotlib color值,表示线条的颜色,

    • .dash_capstyle属性:为'butt' or 'round' or 'projecting',表示虚线头端类型

    • .dash_joinstyle属性:为'miter' or 'round' or 'bevel',表示虚线连接处类型

    • .dashes属性:一个数值序列,表示虚线的实部、虚部的尺寸。如果为(None,None)则虚线成为实线

    • .drawstyle属性:为'default'or'steps'or'step-pre'or'step-mid'or'step-post',表示曲线类型。

      • 'default':点之间以直线连接
      • 'steps*':绘制阶梯图。其中steps等价于steps-pre,是为了保持兼容旧代码
    • .fillstyle属性:为'full'or'left'or'right'or'bottom'or'top'or'none'表示marker的填充类型。

      • 'full':填充整个marker
      • none:不填充marker
      • 其他值:表示填充一半marker
    • .linestyle或者ls属性:指定线型,可以为以下值:

      • '-'或者'solid':表示实线
      • '--'或者dashed:表示虚线
      • '-.'或者dash_dot:表示点划线
      • ':'或者'dotted':表示点线
      • 'None'或者' '或者'':表示没有线条(不画线)
    • .linewidth或者lw属性:为浮点值,表示线条宽度

    • .marker属性:可以为一系列的字符串,如'.'、','、'o'....,表示线条的marker

    • .markeredgecolor或者.mec属性:可以为matplotlib color,表示marker的边的颜色

    • .markeredgewidth或者.mew属性:可以为浮点数,表示marker边的宽度

    • .markerfacecolor或者.mfc属性:可以为matplotlib color,表示marker的前景色

    • .markerfacecoloralt或者.mfcalt属性:可以为matplotlib color,表示marker的可选前景色

    • .markersize或者.ms属性:可以为浮点数,表示marker的大小

    • .markevery属性:指定每隔多少个点绘制一个marker,可以为以下值:

      • None:表示每个点都绘制marker
      • N:表示每隔N个点绘制marker,从0开始
      • (start,N):表示每隔N个点绘制marker,从start开始
      • [i,j,m,n]:只有点i,j,m,nmarker绘制
      • …其他值参考文档
    • .pickradius属性:浮点值,表示pick radius

    • .solid_capstyle属性:可以为'butt'、'round'、'projecting',表示实线的头端类型

    • .sold_joinstyle属性:可以为'miter'、'round'、'bevel',表示实线连接处的类型

    • .xdata属性:可以为一维的numpy.array,表示x轴数据

    • .ydata属性:可以为一维的numpy.array,表示y轴数据

    b. Text类

    1. matplotlib.text.Text类是绘制文字的类(基类是matplotlib.artist.Artist)。它的构造函数为:

      这些关键字参数也是属性。其属性有:

    • 继承自Artist基类的属性: .alpha.animated.axes.clip_box、..clip_on.clip_path.contains.figure.gid.label.picker.transform.url.visible.zorder

    • .backgroundcolor属性:背景色,可以为任何matplotlib color

    • .bbox属性:文本框的边框。其值是FancyBboxPatch类的属性字典。

    • .color属性:字体颜色,可以为任何matplotlib color

    • .family或者.name或者.fontfamily或者.fontname属性:字体的名字。可以是string或者string list(表示可以为若干个名字,优先级依次递减)。string必须是一个真实字体的名字,或者一个字体的class name

    • .fontproperties或者.font_properties属性:字体的属性,值是一个matplotlib.font_manager.FontProperties实例(该实例一次性设置字体的很多属性,比如字体类型、字体名字、字体大小、宽度、…)

    • .horizontalalignment或者.ha属性:水平对齐方式,可以为'center'、'right'、'left'

    • .linespacing属性:为浮点数,单位为font size,表示行间距

    • .multialignment属性:multiline text对齐方式,可以为'left'、'right'、'center'

    • .position属性:为一个元组(x,y),表示文本框的位置

    • .rotation属性:字体旋转角度。可以为下列值:

      • 浮点数,表示角度
      • 'vertical'、'horizontal'
    • .rotation_mode属性:旋转模式。可以为下列值:

      • 'anchor':文本首先对齐,然后根据对齐点来旋转
      • None:文本先旋转,再对齐
    • .size或者.fontsize属性:字体大小。可以为下列值:

      • 浮点值,表示字体大小
      • 'xx-small'、'x-small'、'small'、'medium'、'large'、'x-large'、'xx-large'
    • .style或者.fontstyle属性:字体样式,可以为'normal'、'italic'、'oblique'

    • .text属性:文本字符串,可以为任意字符串(他可以包含'\n'换行符或者LATEX语法)

    • .variant或者.fontvariant属性:表示字体形变,可以为下列值:'normal'、'small-caps'

    • .verticalalignment或者.ma或者.va属性:表示文本的垂直对齐,可以为下列值:

    • .weight或者.fontweight属性:设置字体的weight,可以为下列值:

      • 一个整数值,在[0—-1000]之间
      • 'ultralight''light''normal''regular''book‘、'medium''roman''semibold''demibold''demi''bold''heavy''extrabold''black'
    • .x属性:一个浮点值,表示文本框位置的x

    • .y属性:一个浮点值,表示文本框位置的y

    c. Annotation类

    1. matplotlib.text.Annotation类是图表中的图式,它是一个带箭头的文本框,用于解说图表中的图形。它的基类是matplotlib.text.Textmatplotlib.text._AnnotationBase。其构造函数为:

      在位置xytext处放置一个文本框,该文本框用于解释点xy,文本框的文本为s

    • s:文本框的文本字符串

    • xy:被解释的点的坐标

    • xytext:文本框放置的位置。如果为None,则默认取xy

    • xycoordsxy坐标系,默认取'data'坐标系(即xy是数据坐标系中的点)。可以为以下值:

      • 'figure points':从figure左下角开始的点
      • 'figure pixesl':从figure左下角开始的像素值
      • 'figure fraction'(0,0)代表figure的左下角,(1,1)代表figure的右上角
      • 'axes points':从axes左下角开始的点
      • 'axes pixels':从axes左下角开始的像素
      • 'axes fraction'(0,0)代表axes的左下角,(1,1)代表axes的右上角
      • 'data':使用被标注对象的坐标系
      • 'offset points':指定从xy的偏移点
      • 'polar':极坐标系
    • textcoords:文本框坐标系(即xytext是文本坐标系中的点),默认等于xycoords

    • arrowprops:指定文本框和被解释的点之间的箭头。如果不是None,则是一个字典,该字典设定了matplotlib.lines.Line2D的属性。

      • 如果该字典有一个arrowstyle属性,则该键对应的值也是一个字典,创建一个FancyArrowsPatch实例,实例属性由该字典指定。
      • 如果该字典没有arrowstyle属性,则创建一个YAArrow实例,
    • annotation_clip:控制超出axes区域的annotation的显示。如果为Trueannotation 只显示位于axes区域内的内容。

    • 额外的关键字参数全部是设置Text的属性

    d. Legend

    1. matplotlib.legend.Legend是图例类,它的基类是matplotlib.artist.Artist。其构造函数为:

      其关键字参数为:

    • parent:持有该legendartist

    • loc:图例的位置。其值可以为字符串或者数字:

      • best或0:自动计算
      • upper right或1: 右上角
      • upper left或2:上角
      • lower left或3:下角
      • lower right或4:右下角
      • right或5:右边
      • center left或6:中间偏左
      • center right或7:中间偏右
      • lower center或8:中间底部
      • upper center或9:中间顶部
      • center或10:正中央
    • handle:一个artist列表,添加这些artistlegend

    • lebels:一个字符串列表添加到legend

    • prop:字体属性

    • fontsize: 字体大小(只有prop未设置时有效)

    • markerscale: marker的缩放比例(相对于原始大小)

    • markerfirst: 如果为True,则marker放在label左侧;否则marker放在label右侧

    • numpoints: the number of points in the legend for line

    • scatterpoints: the number of points in the legend for scatter plot

    • scatteryoffsets: a list of offsets for scatter symbols in legend

    • frameon: if True, draw a frame around the legend. If None, use rc

    • fancybox: if True, draw a frame with a round fancybox. If None, use rc

    • shadow: if True, draw a shadow behind legend

    • framealpha: If not None, alpha channel for the frame.

    • ncol: number of columns

    • borderpad: the fractional whitespace inside the legend border

    • labelspacing: the vertical space between the legend entries

    • handlelength: the length of the legend handles

    • handletextpad: the pad between the legend handle and text

    • borderaxespad: the pad between the axes and legend border

    • title: 图例的标题

    • bbox_to_anchor: the bbox that the legend will be anchored.

    • bbox_transform: the transform for the bbox. transAxes if Noneloc a location code

    • 其他关键字参数用于设置属性

    属性为:

    • 继承自Artist基类的属性: .alpha.animated.axes.clip_box、..clip_on.clip_path.contains.figure.gid.label.picker.transform.url.visible.zorder

    e. Patch类

    1. matplotlib.patches.Patch类是二维图形类。它的基类是matplotlib.artist.Artist。其构造函数为:

      参数为:

    • edgecolor:可以为matplotlib color,表示边线条的颜色,若为none则表示无颜色

    • facecolor:可以为matplotlib color,表示前景色,若为none则表示无颜色

    • color可以为matplotlib color,表示边线条和前景色的颜色。

    • linewidth:为浮点数,表示线条宽度

    • linestyle:指定线型,可以为以下值:

      • '-'或者'solid':表示实线
      • '--'或者dashed:表示虚线
      • '-.'或者dash_dot:表示点划线
      • ':'或者'dotted':表示点线
      • 'None'或者' '或者'':表示没有线条(不画线)
    • antialiased:一个布尔值。如果为True则表示线条是抗锯齿处理的

    • hatch:设置hatching pattern,可以为下列的值:

      • '\''|''-''+''x''o''0''.''*'
    • fill:为布尔值。如果为True则填充图形,否则不填充

    • capstyle:为'butt' or 'round' or 'projecting',表示线条头端类型

    • :可以为'miter'、'round'、'bevel',表示矩形线条接头类型

    • 其他关键字参数用于设置属性

    属性如下:

    • 继承自Artist基类的属性: .alpha.animated.axes.clip_box、..clip_on.clip_path.contains.figure.gid.labelpath_effects.picker.transform.url.visible.zorder

    • .antialiased或者.aa属性:一个布尔值。如果为True则表示线条是抗锯齿处理的

    • .capstyle属性:为'butt' or 'round' or 'projecting',表示线条头端类型

    • .color属性:可以为matplotlib color,表示边线条和前景色的颜色。

    • .edgecolor或者.ec属性:可以为matplotlib color,表示边线条的颜色,若为none则表示无颜色

    • .facecolor或者.fc属性:可以为matplotlib color,表示前景色,若为none则表示无颜色

    • .fill属性:为布尔值。如果为True则填充图形,否则不填充

    • .hatch属性:设置hatching pattern,可以为下列的值:

      • '\''|''-''+''x''o''0''.''*'
    • .joinstyle属性:可以为'miter'、'round'、'bevel',表示矩形线条接头类型

    • .linestyle或者.ls属性:指定线型,可以为以下值:

      • '-'或者'solid':表示实线
      • '--'或者dashed:表示虚线
      • '-.'或者dash_dot:表示点划线
      • ':'或者'dotted':表示点线
      • 'None'或者' '或者'':表示没有线条(不画线)
    • .linewidth或者.lw属性:为浮点数,表示线条宽度

    f. Rectangle 类

    1. matplotlib.patches.Rectangle类是矩形类(基类是matplotlib.patches.Patch),其构造函数为:Rectangle(xy,width,height,angle=0.0,**kwargs)。 参数为:

      • xy:矩形左下角坐标
      • width:矩形宽度
      • height:矩形高度
      • 其他关键字参数用于设置属性

      其属性有:

      • 继承自Artist基类的属性: .alpha.animated.axes.clip_box、..clip_on.clip_path.contains.figure.gid.label.picker.transform.url.visible.zorder
      • 继承自Patch基类的属性: .antialiased或者.aa.capstyle.color.edgecolor或者.ec.facecolor或者.fc.fill.hatch.joinstyle.linestyle或者.ls.linewidth或者.lw属性

    g. Polygon类

    1. matplotlib.patches.Polygon类是多边形类。其基类是matplotlib.patches.Patch。其构造函数为: Polygon(xy, closed=True, **kwargs)。参数为:

      • xy是一个N×2numpy array,为多边形的顶点。
      • closedTrue则指定多边形将起点和终点重合从而显式关闭多边形。
      • 其他关键字参数用于设置属性

      Polygon的属性有:

      • 继承自Artist基类的属性: .alpha.animated.axes.clip_box、..clip_on.clip_path.contains.figure.gid.label.picker.transform.url.visible.zorder
      • 继承自Patch基类的属性: .antialiased或者.aa.capstyle.color.edgecolor或者.ec.facecolor或者.fc.fill.hatch.joinstyle.linestyle或者.ls.linewidth或者.lw属性

    h. PolyCollection类

    1. matplotlib.collections.PolyCollection是多边形集合类,其基类是matplotlib.collections._CollectionWithSizes。它的构造函数为: PolyCollection(verts, sizes=None, closed=True, **kwargs)

      • verts:一个顶点序列。每个顶点都由xy元组或者xy数组组成
      • sizes:一个浮点数序列,依次指定每个顶点正方形的边长。如果序列长度小于顶点长度,则循环从序列头部再开始 挑选
      • closed:如果为True,则显式封闭多边形
      • edgecolors: collection的边的颜色
      • 其他关键字参数用于设置属性

      下面为属性:

      • 继承自Artist基类的属性: .alpha.animated.axes.clip_box、..clip_on.clip_path.contains.figure.gid.label.picker.transform.url.visible.zorder
      • .facecolors: collection的前景色
      • .linewidths: collection的边线宽
      • .antialiaseds:抗锯齿属性,可以为True或者False
      • .offsets: 设置collection的偏移
      • .norm: 归一化对象
      • .cmap: