简体   繁体   English

2D直方图由每个容器中的标准偏差着色

[英]2D histogram coloured by standard deviation in each bin

Is there a way to create a 2D histogram, in Python, where each bin is coloured by standard deviation of points in each bin rather than by point density? 有没有一种方法可以在Python中创建2D直方图,其中每个bin通过每个bin中点的标准偏差而不是点密度来着色?

For example, I have a set of 2D data that looks as follows: 例如,我有一组2D数据,如下所示:

在此处输入图片说明

But I'd like to turn this into a 2D histogram where I expect the purity to decrease in the middle of the gradient-like structure. 但是我想将其转换为2D直方图,我希望其中的纯度在类似梯度的结构中间会降低。

I realise there's no code in this question but if I could be pointed in the right direction to do this efficiently I's be very grateful. 我意识到这个问题中没有代码,但是如果我能为正确的方向指出这一点,我将不胜感激。 Perhaps there is an optimised way to do this already and I could save time rather than creating a matrix or mesh and calculating the standard deviation explicitly? 也许已经有一种优化的方法可以做到这一点,而且我可以节省时间,而不必创建矩阵或网格并显式计算标准偏差?

Take a look at scipy.stats.binned_statistic_2d, then give the function 'std' as the 'statistic' argument. 看一下scipy.stats.binned_statistic_2d,然后将函数“ std”作为“ statistic”自变量。

The documentation somehow seems to leave out the 'std' possibility but in the source code it is available. 该文档似乎以某种方式忽略了“ std”的可能性,但是在源代码中它是可用的。 Otherwise you could give numpy.std as an argument. 否则,您可以给numpy.std作为参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM