我目前有如下代码:
import os
import numpy as np
import pylab
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from matplotlib.patches import Polygon
import numpy as np
...
# Read my image
img = matplotlib.image.imread(p_image)
# Render it, move the coordinates' origin to the upper left corner
plt.imshow(np.flipud(img), cmap=cm.Greys_r,origin='upper')
# Overlay a polygon
p = Polygon( zip(xs,ys), alpha=0.2)
plt.gca().add_artist(p)
# Save it to disk
plt.savefig(p_image_output)
我怎样才能直接将这个数字保存到磁盘而不先在屏幕上渲染它?(请注意,我希望该图保留我传递给的三个参数中指定的属性imshow
)