Is it possible to specify the padding on a specific side of the bbox when adding text in matplotlib? I'm adding a LaTex table as text and for some reason the table is misaligned naturally with no padding specifications. I'd like to account for this for adding padding on the top of the bbox.
Unfortunately, there doesn't seem to be an option for adding padding to a specific side of a bbox. Is this possible?
Here's an example to illustrate:
import matplotlib
matplotlib.rc('text',usetex=True)
import matplotlib.pyplot as plt
import numpy as np
text = '\\begin{tabular}{|c|c|}\\hline 1 & 2 \\\\ \\hline 3 & 4 \\\\ \\hline \\end{tabular}'
plt.imshow(np.zeros((10,10)), cmap=plt.cm.gray)
plt.text( 4.5,
4.5,
text,
fontsize=24,
bbox=dict(fc='w',boxstyle='square,pad=0.5'), va='center', ha='center')
plt.axis('off')
plt.show()