Python matplotlib图像+;点图

Python matplotlib图像+;点图,python,image,matplotlib,plot,overlay,Python,Image,Matplotlib,Plot,Overlay,我想在图像上绘制一些点,并使用以下代码: fig, ax = plt.subplots(1) ax.imshow(img) ax.plot(newModel[:, 0], newModel[:, 1]) ax.set_title("Model tooth " + str(model_number) + ": new model after " + str(it_count) + " iterations") fig.savefig("Fit_models/" + str(file_number)

我想在图像上绘制一些点,并使用以下代码:

fig, ax = plt.subplots(1)
ax.imshow(img)
ax.plot(newModel[:, 0], newModel[:, 1])
ax.set_title("Model tooth " + str(model_number) + ": new model after " + str(it_count) + " iterations")
fig.savefig("Fit_models/" + str(file_number) + "_model_" + str(model_number) + "_newModel.png")
这是可行的,但结果是:

我希望轴从0到图像形状,而不是从-500开始。
另外,我更希望这可以保存在图像的全分辨率上,而不是保存在800x600上。

有关您可以使用的限制:

ax.set_xlim([xmin, xmax])
ax.set_ylim([ymin, ymax])
对于分辨率,您可以使用dpi关键字:

fig.savefig(fname, dpi=400)

您可以调整dpi以获得所需的分辨率。

谢谢,可以了!也可以删除绘图周围的一些空白吗?当然可以。使用
plt.show()
显示绘图,并使用
Configure subplot
工具根据需要调整空白。然后用plt.subplot\u adjust(底部=0.1,顶部=…,左侧=…,右侧=…)在脚本中设置这些值。。如果它解决了你的问题,也请接受我的回答。好的,我去掉了左右的空格,但是上面和下面的空格仍然存在。这些参数似乎都不会影响它。您也可以尝试
plt.tight\u layout()
。另请参见。