不确定如何使 plt.hist2d 实际上 return 变量

Unsure how to make plt.hist2d actually return variables

根据 plt.hist2d 函数的文档,它应该绘制密度分布和 return 三个变量:xedgesyedgesh. h 应该是样本的二维直方图,例如绘制的二维数组。然而,当我使用这个函数时,它似乎认为我要求它 return 超过三个变量。我是 运行:

myHist, xedges, yedges = plt.hist2d(X, Y, bins=(np.linspace(-0.5,2,50),np.linspace(0,2.5,50)), cmap=plt.cm.Reds, cmin=1) 

并得到错误: ValueError: too many values to unpack (expected 3)

有什么建议吗?我正在使用 python3.

根据documentation for hist2d方法,它returns四个变量:hxedgesyedgesimage .

Returns:

h : 2D array The bi-dimensional histogram of samples x and y. Values in x are histogrammed along the first dimension and values in y are histogrammed along the second dimension.

xedges : 1D array The bin edges along the x axis.

yedges : 1D array The bin edges along the y axis.

image : QuadMesh