簡體   English   中英

Python Matplotlib圖像+點圖

[英]Python matplotlib image + points plot

我想在圖像上繪制一些點,並為此使用以下代碼:

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以獲得所需的分辨率。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM