plotting.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:treecat 作者: posterior 项目源码 文件源码
def plot_chord(begin, end, spacing, color, alpha=None):
    """Plots a circular chord from begin to end.

    This assumes that the outer circle is centered at (0,0).

    Args:
        begin: A [2]-shaped numpy array.
        end: A [2]-shaped numpy array.
        spacing: A float, extra spacing around the edge of the circle.
        color: A matplotlib color spec.
        apha: A float or None.
    """
    # Adapted from https://matplotlib.org/users/path_tutorial.html
    codes = [Path.MOVETO, Path.CURVE4, Path.CURVE4, Path.CURVE4]
    xy = np.array([begin, begin, end, end])
    dist = ((begin - end)**2).sum()**0.5
    xy[[1, 2], :] *= 1 - 2 / 3 * dist + 1 / 6 * dist**2 - spacing
    path = Path(xy, codes)
    patch = PathPatch(
        path, facecolor='none', edgecolor=color, lw=1, alpha=alpha)
    pyplot.gca().add_patch(patch)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号