1import numpy as np
2import matplotlib.pyplot as plt
3plt.figure()
4ax = plt.subplot(111)
5plt.plot(np.linspace(1,0,1000))
6t = plt.text(0.03,.95,'text',transform=ax.transAxes,backgroundcolor='0.75',alpha=.5)
7plt.show()
1plt_text = plt.text(
2 0.5, # x
3 0.5, # y
4 'your text', # text
5 fontsize=30
6)
7plt_text.set_bbox(dict(
8 facecolor='red', # background color
9 alpha=0.5, # background alpha
10 edgecolor='red' # border color
11))