添加比例尺
在这一步中,我们将使用锚定对象在绘图中添加一个比例尺。
def draw_sizebar(ax):
"""
Draw a horizontal bar with length of 0.1 in data coordinates,
with a fixed label center-aligned underneath.
"""
size = 0.1
text = r"1$^{\prime}$"
sizebar = AuxTransformBox(ax.transData)
sizebar.add_artist(Line2D([0, size], [0, 0], color="black"))
text = TextArea(text)
packer = VPacker(
children=[sizebar, text], align="center", sep=5) ## separation in points.
ax.add_artist(AnchoredOffsetbox(
child=packer, loc="lower center", frameon=False,
pad=0.1, borderpad=0.5)) ## paddings relative to the legend fontsize.
draw_sizebar(ax)