python - 如何将 matplotlib 图保存到列表中,然后显示它们?
问题描述
我正在运行 Python,并且正在像这样的 for 循环中创建一系列直方图:
hist_dict = {}
for data, name in zip([mon, tue, wed, thu, fri],
['Monday','Tuesday','Wednesday','Thursday','Friday']):
plt.figure()
plt.title("Call Distribution for " + name)
plt.xlabel("Number of Daily Calls")
plt.ylabel("Number of Days")
plt.xlim(0, 1200)
hist_dict[name] = plt.hist(data, bins=24)
将图像保存到我的字典(或列表,我不知道是否重要)后,我可以调用它们并显示它们吗?我努力了
hist_dict["Monday"].show()
plt.show(hist_dict["Monday"])
hist_dict["Monday"]
似乎没有任何效果。如果这不起作用,那么在本地保存图(而不是 png 文件)以便我可以安排到子图设置中的最佳方法是什么?
解决方案
推荐阅读
- asp.net - 如何让 DropDownList 从 TextBox 复制数据?
- android - 用于位置跟踪的前台服务与 WorkManager
- javascript - Vuex:Firebase 路由。如果语句
- json - 遍历 JSONObject
- c# - 如果内容页不包含,则仅在母版页中包含表单标签
- solr - 在使用模式的 solr 中如何在新字段中复制最低价格
- java - 我们如何创建其他枚举的 ENUM 联合
- r - 很简单,为什么 (-1)^(1/3) 在函数中使用时返回 NaN?
- javascript - 如何在 PHP 中解析通过 AJAX 发送的嵌套 JSON
- html - 防止表格垂直拉伸以填满表格