I'm cross-posting a question I asked on SO:
How can I vertically align text in matplotlib? My situation is as follows:
I'm using `ImageGrid`, to plot a row of five images:
grid = ImageGrid(fig,
rect=(0.06, 0., 0.885, 1.),
nrows_ncols = (1, 5),
axes_pad = 0.,
label_mode = "L",
share_all = True,
Within each axes, I want to add some text. For this, I defined the
following function (following one of the examples):
def add_inner_title(ax, title, loc, props):
from matplotlib.offsetbox import AnchoredText
at = AnchoredText(title, loc=loc, prop=props,
which I use like this:
ax = grid[i]
tit = add_inner_title(ax, title, loc=3,
'weight' : 'bold',
'va' : 'baseline'})
Now, in one of the plots, the axes, the title is "Pollution Signal", in
another, it is "one", and in another, it is "GOME" (all just examples).
The problem is that now the texts are not vertically aligned: The
baseline of the text with a *g* is higher to accomodate for the needed
space below the baseline.
How can I achieve that in my case, all texts are vertically aligned,
given that the heights of the individual text boxes are different?
Any help is greatly appreciated!