如何规范化 hexbin 图? [英] How do I normalize a hexbin plot?

查看:36
本文介绍了如何规范化 hexbin 图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 hexbin 图中有两个分布,如图所示:

I have two distributions within a hexbin plot, like the one shown:

一个分布的最大值约为4000,而另一个分布的最大值约为2500.因此,绘制颜色是不同的.

One distributions has a max value of about 4000, while the other has a max value of about 2500. The plotting colours are therefore different.

我想如果我知道 hexbin 图的最大值,我可以将它标准化.除了查看颜色条外,我如何知道最大六边形内有多少个点?我正在使用 matplotlib.pyplot.hexbin

I was thinking I could normalize it if I knew the max value of the hexbin plot. How do I know how many points are within the max hexbin other than looking at the colorbar? I am using matplotlib.pyplot.hexbin

推荐答案

您可以获得规范的最小值和最大值,该规范用于对数据进行标准化以进行颜色选择.

You can get the min and max of the norm which is what is used to normalize the data for color picking.

hb = plt.hexbin(x, y)
print hb.norm.vmin, hb.norm.vmax

然后您可以继续将此信息的范数传递给第二个图.问题在于,第一个绘图必须比第二个绘图具有更大的范围,否则第二个绘图将不会全部被着色.

You could then go on to pass a norm with this information to the second plot. The problem with this is that the first plot must have more range than the second, otherwise the second plot will not all be colored.

或者,您可以构建一个范数,并将其传递给两个图的 hexbin 函数:

Alternatively, and preferably, you can construct a norm which you pass to the hexbin function for both of your plots:

norm = plt.normalize(min_v, max_v)
hb1 = plt.hexbin(x1, y1, norm=norm)
hb2 = plt.hexbin(x2, y2, norm=norm)

HTH,

这篇关于如何规范化 hexbin 图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆