change dpi matplotlib code example Example: change pyplot dpi plt.imshow(img) plt.gcf().set_dpi(300) plt.show()