How to normalize the hexbin chart?

I have two distributions in a hexbin plot, as shown in the figure: enter image description here

One distribution has a maximum value of about 4000, while the other has a maximum value of about 2500. Thus, the colors of the graph are different from each other.

I thought I could normalize it if I knew the maximum value of the hexbin graph. How to find out how many points are within max hexbin, except how to look at the color panel? I am using matplotlib.pyplot.hexbin

+7
source share
1 answer

You can get the minimum and maximum rates that are used to normalize data for color selection.

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

Then you can go to the norm with this information to the second plot. The problem is that the first graph should have a larger range than the second, otherwise the second graph will not be colored.

Alternatively, and preferably, you can build the rate that you pass to the hexbin function for both of your graphs:

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

NTN

+8
source

Source: https://habr.com/ru/post/921276/


All Articles