I'm trying to position some additional annotations to line up with the axis label text in a matplotlib figure. How is this position calculated, as a function of the font size of the tick and axes labels, and the font size of the annotation?
Specifically, given a figure with a single set of tick labels and a single axis label along the x-axis, with font sizes tick_font_size
and label_font_size
respectively, what is the vertical position y
in figure points that would result in
ax.annotate('Some text', (x, y), va='top', ...)
placing 'Some text'
with font size annotation_font_size
, in vertical alignment with the axis label?
For various reasons, I must use annotate
for this, and va='top'
is a constraint; and I need to use the font size information above — that is, I'm looking for the function of the form
y = f(tick_font_size, label_font_size, annotation_font_size)
with all values in figure points (i.e., usable with textcoords='offset points'
in annotate
). Such an algorithm must exist, since it is clearly used by matplotlib
to position the axis label in the first place.