<code>1.matplotlib.patch基本用法</code>
<code>matplotlib.patch</code>对象底层的对象就是<code>Path</code>。它的基本用法如下:

2.<code>matplotlib.path.Path(verts,codes)</code>
<code>PATH</code>对象的创建通过<code>matplotlib.path.Path(verts,codes)</code>创建
参数:
<code>verts</code>:<code>PATH</code>的顶点。这些顶点必须构成一个封闭曲线。其中每个顶点必须指定<code>x</code>坐标和<code>y</code>坐标。
<code>codes</code>:指示如何使用这些<code>PATH</code>顶点。它与<code>verts</code>关系是一一对应的。有如下指令:
<code>Path.STOP</code>:结束<code>path</code>的标记
<code>Path.MOVETO</code>:画笔提起并移动到指定的顶点
<code>Path.LINETO</code>:画笔画直线,从<code>current position</code>到指定的顶点
<code>Path.CURVE3:</code>画笔画二阶贝塞尔曲线,从<code>current position</code>到指定的<code>end point</code>, 其中还有一个参数是指定的<code>control point</code>
<code>Path.CURVE4</code>:画笔画三阶贝塞尔曲线,从<code>current position</code>到指定的<code>end point</code>, 其中还有两个参数是指定的<code>control points</code>
<code>Path.CLOSEPOLY</code>:指定的<code>point</code>参数被忽略。该指令画一条线段, 从<code>current point</code>到<code>start point</code>
可以通过<code>matplotlib.patches.PathPatch(path)</code>来构建一个<code>PathPatch</code>对象,然后通过<code>Axes.add_patch(patch)</code>向<code>Axes</code>添加<code>PathPatch</code>对象.这样就添加了<code>Path</code>到图表中。
举例:
3.在<code>matplotlib</code>中所有简单的<code>patch primitive</code>,如<code>Rectangle</code>、<code>Circle</code>、<code>Polygon</code>等等,都是由简单的<code>Path</code>来实现的。而创建大量的<code>primitive</code>的函数如<code>hist()</code>和<code>bar()</code>(他们创建了大量的<code>Rectanle</code>)可以使用一个<code>compound path</code>来高效地实现。
但是实际上<code>bar()</code>创建的是一系列的<code>Rectangle</code>,而没有用到<code>compound path</code>,这是由于历史原因,是历史遗留问题。(<code>bar()</code>函数先于<code>Coupound Path</code>出现)
下面是一个<code>Compound Path</code>的例子:
在创建<code>Axes</code>或者<code>SubPlot</code>时,可以给构造函数提供一个<code>axisbg</code>参数来指定背景色