【发布时间】:2014-08-27 03:31:51
【问题描述】:
我想更改图表的背景图像。经过一些研究,我发现了这种方法:
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)
我必须将后台调用放在哪里?是常见问题还是我拨打的电话正在覆盖背景更改?感谢您的帮助。
【问题讨论】:
-
到底是什么问题?你能举一个最小的可运行示例(你有很多变量没有给出值并删除所有与你的问题无关的命令(我不认为设置标题会影响它))?
标签: python matplotlib seaborn