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
评论列表
文章目录