我是 Python 和 Spyder 的新手。我使用的是 Python 2.7.13 和 Spyder 3.1.4。我无法plt.show()处理我的数据,也无法从网站上重现简单的直方图示例。plt.draw()也不起作用。我已将图形后端从内联更改为自动,将 Qt4 更改为 Qt5 作为提出的类似问题,但这些都没有奏效。如果fig在 IPython 控制台中键入,它将显示图形。我在这里发布示例。任何有关如何解决此问题的建议表示赞赏。
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
mu, sigma = 100, 15
x = mu + sigma * np.random.randn(10000)
fig = plt.figure()
ax = fig.add_subplot(111)
# the histogram of the data
n, bins, patches = ax.hist(x, 50, normed=1, facecolor='green', alpha=0.75)
# hist uses np.histogram under the hood to create 'n' and 'bins'.
# …Run Code Online (Sandbox Code Playgroud)