参考本教程:http : //matplotlib.org/1.4.0/examples/pylab_examples/contour_demo.html
这是来自 mplotlib.mlab 的 bivariate_normal 函数的原型:
bivariate_normal(X, Y, sigmax=1.0, sigmay=1.0, mux=0.0, muy=0.0, sigmaxy=0.0)
Run Code Online (Sandbox Code Playgroud)
X 和 Y 定义网格,我们有二维均值和协方差项的参数。如您所见,最后有一个关于 x 和 y 之间协方差的参数。事情是这样的:如果 sigmaxy = 0,plt.contour() 将绘制二元法线轮廓。但是,如果 sigmaxy 有任何其他值,我会得到一个
ValueError: zero-size array to reduction operation minimum which has no identity
Run Code Online (Sandbox Code Playgroud)
例如,
Z = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0, 0.0)
plt.contour(X,Y,Z)
Run Code Online (Sandbox Code Playgroud)
作品
但是,以下方法不起作用:
Z = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0, 1.0)
plt.contour(X,Y,Z)
Run Code Online (Sandbox Code Playgroud)
任何熟悉 matplotlib 的人有什么想法吗?谢谢。