这是来自的代码这个例子 http://matplotlib.org/users/recipes.html#placing-text-boxes:
# these are matplotlib.patch.Patch properties
props = dict(boxstyle='round', facecolor='wheat', alpha=0.5)
# place a text box in upper left in axes coords
ax.text(0.05, 0.95, textstr, transform=ax.transAxes, fontsize=14,
verticalalignment='top', bbox=props)
Matplotlib 坐标
Using transform=ax.transAxes
我们可以使用坐标系将元素放入绘图中,其中点 (0, 0) 为左下角,(0, 1) 为左上角,(1, 1) 为右上角,依此类推。
具体来说:如果我们使用位置 (0, 0) 放置一个文本框,则称为特定点anchor
将被放置在左下角。要更改锚点,您需要向函数调用添加两个参数:verticalalignment
(可能的值:center
, top
, bottom
, baseline
) and horizontalalignment
(可能的值:center
, right
, left
).
所以要将box放在左下角,需要将box的左下角放在图中的左下角:
# place a text box in lower left in axes coords
ax.text(0.05, 0.05, textstr, transform=ax.transAxes, fontsize=14,
verticalalignment='bottom', bbox=props)
不管怎样,这里是链接ipython-notebook 包含所有展示位置的示例 https://gist.github.com/jbzdak/8183530.