小编Rez*_*ani的帖子

用python加权元素制作六边形图

通过在python中使用matplotib,可以通过提供要绘制的项目列表以及权重列表来制作简单的直方图,从而根据其权重来调整每个项目对其所属仓位的贡献,例如

import matplotlib.pyplot as plt

...

plt.hist(items, weights = weightsOfItems)
Run Code Online (Sandbox Code Playgroud)

我正在尝试绘制两个值的六边形bin直方图,可以使用

plt.hexbin(xValues, yValues)
Run Code Online (Sandbox Code Playgroud)

和以前一样,我希望根据权重列表调整每对对所属箱的贡献。从hexbin文档看来,我应该可以通过为参数C提供输入来做到这一点,即

plt.hexbin(xValues, yValues, C = weightsOfValues)
Run Code Online (Sandbox Code Playgroud)

但是,这样做会产生完全不正确的图。目前,我已先根据权重对xValue和yValue进行采样,以得出xSamples和ySamples。但是,此过程非常耗时,并且这意味着我没有使用所有可用数据,因为我摆脱了样本中未包含的xValues和yValues。

那么,有谁知道一种产生六边形柱状图直方图的方法,其中根据给定的权重来调整值对它们各自的柱状图的贡献?

python plot matplotlib hexagonal-tiles

5
推荐指数
1
解决办法
1052
查看次数

标签 统计

hexagonal-tiles ×1

matplotlib ×1

plot ×1

python ×1