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