【发布时间】:2017-11-23 11:21:45
【问题描述】:
考虑这段代码:
fig = Figure()
canvas = FigureCanvas(fig)
ax = fig.gca()
ax.text(0.0,0.0,"Test", fontsize=45)
ax.axis('off')
canvas.draw() # draw the canvas, cache the renderer
width, height = fig.get_size_inches() * fig.get_dpi()
images = np.fromstring(canvas.tostring_rgb(), dtype='uint8').reshape(int(height), int(width), 3)
所以我遇到的问题是它保存了带有文本“测试”的情节。但是假设我有一个图,确切地说是“AxesImages”matplotlib,我怎样才能转换图像图而不是文本?我试图用 ax.imshow(axesImage) 更改 ax.text(...) 但它抛出错误。
有什么建议吗?
【问题讨论】:
标签: python matplotlib