python-3.x - 关闭、打开、枚举绘图 - 在 python matplotlib 中
问题描述
使用 spyder 和 Python 3.7
我使用此代码绘制图形:
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(0, 1100, 1)
y = np.sin(2 * x * np.pi / 180)
fig, ax = plt.subplots()
ax.plot(x, y)
ax.set_title('A single plot')
当我一次又一次地运行该程序时,它每次运行都会打开一个新图形。我想要的是能够在再次绘制之前关闭一个特定的图形。像这样的东西:
fig = fig(1)
plt.close(fig(1))
...create new fig...
plt.open(fig(1))
plt.show()
但是上面是错误的, plt.show() 没有效果。
这看起来很简单——它不起作用。
解决方案
推荐阅读
- rust - 在 Rust 中,返回具有生命周期依赖项的迭代器的最佳方法是什么?
- perl - 如何使用 Perl IPC::Run3 从子进程中读取标准输出和标准错误?
- java - 为什么 Java 不使用 jasper studio 中 .jrxml 文件中配置的字体导出 PDF?
- php - 如何通过在foreach中传递一个对象来循环数组
- apache - 我的默认用户管理员无法终止 PID 4 的进程
- android - ReactNative Android 没有将文件保存到外部存储
- powerbi-embedded - 嵌入 PowerBI 仪表板
- r - ggplot:创建一个自由比例的平面网格
- javascript - 过滤下拉列表中的多个数据属性
- gradle - “grails prod war”无法解析存储库中的 javax.servlet-api 3.1.0