I am trying to put some text with a background on the matplotlib shape, with the text and background becoming transparent. Following code
import numpy as np import matplotlib.pyplot as plt plt.figure() ax = plt.subplot(111) plt.plot(np.linspace(1,0,1000)) t = plt.text(0.03,.95,'text',transform=ax.transAxes,backgroundcolor='0.75',alpha=.5) plt.show()
makes the text translucent relative to the text background, but the background is not at all transparent relative to the line that it hides in the picture.
t.figure.set_alpha(.5)
and
t.figure.patch.set_alpha(.5)
also don't do the trick.
source share