m-thesis-introduction/lib/plotting.py

25 lines
600 B
Python

"""
Routines to assist in plotting
"""
def annotate_width(ax, name, x1, x2, y, text_kw={}, arrow_kw={}):
default_arrow_kw = dict(
xy = (x1, y),
xytext = (x2,y),
arrowprops = dict(
arrowstyle="<->",
shrinkA=False,
shrinkB=False
),
)
default_text_kw = dict(
va='bottom',
ha='center',
xy=((x1+x2)/2, y)
)
an1 = ax.annotate("", **{**default_arrow_kw, **arrow_kw})
an2 = ax.annotate(name, **{**default_text_kw, **text_kw})
return [an1, an2]