Matplotlibs pyplot.subplots() 使内核崩溃

Max*_*Max 6 python matplotlib

当使用超过 1 个绘图时,使用 matplotlibs pyplot(在本例中导入为 plt)会使我的内核(Win7 下的 Py3.5)崩溃。更具体地说,轴对象会导致崩溃。崩溃立即发生并杀死所有正在运行的 python 实例。

例如打电话

fig,ax = plt.subplots(2,2)
Run Code Online (Sandbox Code Playgroud)

崩溃。尽管

ret = plt.subplots(2,2)
fig = ret[0]
Run Code Online (Sandbox Code Playgroud)

工作正常,然后调用时崩溃

ax = ret[1]
Run Code Online (Sandbox Code Playgroud)

或者

ax1 = ret[1][0]
Run Code Online (Sandbox Code Playgroud)

或类似的

这是一个已知的问题?

小智 2

我也遇到了类似的问题,但我可以使用这种方式摆脱崩溃问题。

import matplotlib
matplotlib.use("TKAgg")
import matplotlib.pyplot as plt

fig,ax=plt.subplots(1, 1)
Run Code Online (Sandbox Code Playgroud)

这对我有用。试一试。

希望能帮助到你。

最好的祝愿