我有这段简短的matplotlib代码用于测试目的,但是无论我是否使用交互模式,对show()
的调用都不会执行任何操作。是什么原因呢?
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
X = np.random.rand(100)
hist, edges = np.histogram(X, bins=16)
xpos = edges[:-1]
ypos = np.zeros_like(edges[:-1])
zpos = ypos
dx = 0.5 * np.ones_like(xpos)
dy = dx
dz = hist
ax.bar3d(xpos, ypos, zpos, dx, dy, dz, zsort='average')
fig.show(warn=True)