首页 > 解决方案 > 将 matplotlib 条形图打印到 txt 文件

问题描述

我创建了一个条形图,并希望将其写入 txt 文件。而不是使用 plt.show(),它只是显示一个图像,或者使用 plt.savefig() 保存它,我想将条形图写入我的文件

我目前正在打开我的 txt 文件,并想将我的 marplot 添加到它,如下所示

with open('filename', 'w') as f: 
  f.write(some lines) 
  somehow write bar plot here 
  f.write(some more lines)

标签: pythonmatplotlib

解决方案


推荐阅读