目前,matplotlib的写入功能要求
seekducktype在文件中使用响应。您可以像这样写入缓冲区:
import iodef mplimage(request): f = matplotlib.figure.Figure() # Code that sets up figure goes here; in the question, that's ... FigureCanvasAgg(f) buf = io.BytesIO() plt.savefig(buf, format='png') plt.close(f) response = HttpResponse(buf.getvalue(), content_type='image/png') return response
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)