3
我试图在Python中使用Matplotlib来显示图像并在其上的各个点上显示文本。我想让图像部分透明,以增加文字的可见度。在matplotlib中设置图像背景颜色
但是,我想图像背后的背景颜色是白色而不是灰色,我无法弄清楚如何让这种变化坚持下去。这是我所在的地方。
img = plt.imread("counties.png")
fig, ax = plt.subplots()
plt.axis('off')
plt.text(.6, .68,'matplotlib', ha='center', va='center',
transform=ax.transAxes, color=(0,.16,.48), fontname='Kanit Light')
plt.text(.5, .5,'test', ha='center', va='center', transform=ax.transAxes,
color=(0,.16,.48))
ax.imshow(img, alpha=0.05)
plt.show()
查看照片counties.png。 – Serenity