Closed
Description
When using AnchoredText, setting the horizontal alignment to 'center' causes the text to be centered around the left-most edge of the text space. In other words, the text is being centered around the location of the the left spine of the text box plus the padding amount.
If you try to right-align the text, the entire text is actually found to the left of the text box.
Here's a simple example and figure to illustrate. Note, this works with or without ImageGrid.
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import ImageGrid
from mpl_toolkits.axes_grid.anchored_artists import AnchoredText
fig = plt.figure()
# grid = ImageGrid(fig, 111, nrows_ncols=(1,1))
# ax0 = grid[0]
ax0 = fig.add_subplot(111)
title = 'Test Test Test Test Test'
at = AnchoredText(title, prop=dict(size=24, horizontalalignment='center'),
frameon=True, loc=9, borderpad=0.5, pad=0.5)
at.patch.set_boxstyle("round, pad=0, rounding_size=0.25")
ax0.add_artist(at)
plt.show()
Here are a couple of issues and pull requests that could be related.