グラフの背景画像を変更したい。いくつかの調査の後、私はこの方法を見つけました:
img = imread("name.jpg")
plt.scatter(x,y,zorder=1)
plt.imshow(img,zorder=0)
plt.show()
それは正常に動作し、その中にグラフを含むウィンドウを作成します。ただし、グラフをファイルに保存する必要がある場合は機能しないことがわかりました。
私は次のようなものを持っています:
plt.clf()
axe_lim = int(max([abs(v) for v in x_values+y_values])*1.4)
plt.plot(x_values, y_values)
plt.gcf().set_size_inches(10,10,forward='True')
plt.axhline(color='r')
plt.axvline(color='r')
plt.title(label.upper(), size=25)
plt.xlim((-axe_lim,axe_lim))
plt.ylim((-axe_lim,axe_lim))
plt.xlabel(units)
plt.ylabel(units)
plt.grid(True)
plt.tight_layout()
img = imread("name.jpg")
plt.imshow(img)
plt.savefig(plot_pict)
バックグラウンドの呼び出しはどこに置く必要がありますか? よくある問題ですか、それとも私が行った呼び出しがバックグラウンドの変更を上書きしていますか? 助けてくれてありがとう。