【发布时间】:2016-02-07 03:45:43
【问题描述】:
在 matplotlib 中添加文本时,是否可以在 bbox 的特定一侧指定填充?我正在添加一个 LaTex 表格作为文本,由于某种原因,表格自然未对齐,没有填充规范。我想说明这一点,以便在 bbox 顶部添加填充。
不幸的是,似乎没有向 bbox 的特定侧添加填充的选项。这可能吗?
这里有一个例子来说明:
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()
【问题讨论】:
-
another question 的答案也可能在这里使用。
标签: python matplotlib latex