mpl_animate.py 文件源码

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

项目:phoebe2 作者: phoebe-project 项目源码 文件源码
def apply_limits(ax, pad=0.1):
    """
    apply the stored phoebe_limits to an axes, applying an additional padding

    :parameter ax:
    :parameter float pad: ratio of the range to apply as a padding (default: 0.1)
    """

    #try:
    if True:
        xlim = ax._phoebe_xlim
        ylim = ax._phoebe_ylim
        zlim = ax._phoebe_zlim
    #except AttributeError:
    #    return ax

    # initialize new lists for the padded limits.  We don't want to directly
    # edit xlim, ylim, zlim because we need padding based off the originals
    # and we don't want to have to worry about deepcopying issues
    xlim_pad = xlim[:]
    ylim_pad = ylim[:]
    zlim_pad = zlim[:]

    xlim_pad[0] = xlim[0] - pad*(xlim[1]-xlim[0])
    xlim_pad[1] = xlim[1] + pad*(xlim[1]-xlim[0])
    ylim_pad[0] = ylim[0] - pad*(ylim[1]-ylim[0])
    ylim_pad[1] = ylim[1] + pad*(ylim[1]-ylim[0])
    zlim_pad[0] = zlim[0] - pad*(zlim[1]-zlim[0])
    zlim_pad[1] = zlim[1] + pad*(zlim[1]-zlim[0])

    if isinstance(ax, Axes3D):
        ax.set_xlim3d(xlim_pad)
        ax.set_ylim3d(ylim_pad)
        ax.set_zlim3d(zlim_pad)
    else:
        ax.set_xlim(xlim_pad)
        ax.set_ylim(ylim_pad)

    return ax
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号