I know that I can produce a png plot with a transparent background in the following way (which works for me):
import matplotlib.pyplot as plt
plt.plot ([1,2,3],[2,1,3])
plt.savefig("test.png",transparent=True)
But how can I make the background semi-transparent, with an fractional alpha number? I read on a separate blog that one could do it like this:
fig,ax=plt.subplots()
ax.plot ([1,2,3],[2,1,3])
ax.patch.set_facecolor('white')
ax.patch.set_alpha(0.5)
plt.savefig('test.png', facecolor=fig.get_facecolor(), edgecolor='none')
But that didn't work for me and produces a plot without transparency and gave me this non transparent png (confirmed in ppt).
In response to the comments,
plt.get_backend()
gives me 'MacOSX' and I am on
Python 3.9.4 (default, Apr 5 2021, 01:49:30) [Clang 12.0.0 (clang-1200.0.32.29)] on darwin