mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-11-13 10:03:32 +01:00
26 lines
600 B
Python
26 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]
|