Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I print a list of the outputs from the hexbin reduce_C_function?
    text
    copied!<p>I have hexagram binned data, and use C=vel to color code by velocity. This works fine, but I would like a list of the calculated standard deviations and a list of the number of objects in each hexagram. I use:</p> <pre><code>imageh=plt.hexbin(x,y,C=vel,extent[np.min(x),np.max(x),np.min(y),np.max(y)],alpha=0.7,gridsize=20,cmap=get_cmap("jet"),reduce_C_function=np.std,mincnt=5) cbar=plt.colorbar(imageh,extend='max') </code></pre> <p>The 'reduce_C_function=np.std' gives me the standard deviation of velocity (vel) in each hexagram, which is what I want, but I also want it to print the vector to the screen. Coordinates x and y can be retrieved via:</p> <pre><code>bv=imageh.get_paths() for j in xrange(len(bv)): xav=np.mean(bv[j].vertices[0:6,0]) yav=np.mean(bv[j].vertices[0:6,1]) </code></pre> <p>I thought that I could get the number of items in each hexagon with get_array and get_offset:</p> <pre><code>counts=imageh.get_array() verts=imageh.get_offsets() </code></pre> <p>but my get_offsets() creates an empty vector and get_array() seems to be returning the average velocity value per hexagon.... My velocity values 'vel' is 5513 items long, counts=imageh.get_array() returns 146 values in the same range as my velocity. I ran it again three times to be sure and on the third try get_array() returned 146 values in the range of the standard deviation. This, if true, would solve part of the problem.</p> <p>I want is the calculated standard deviation of the velocity... the output of the 'reduce_C_function' that is used on the colorbar of the image. I also just want the number found in each hexagram. The goal is to take each standard deviation for each hexagram, divide by the number of points in that hexagram and create weighted standard deviation. The number of points in the hexagram from the raw image I can get seperately by running:</p> <pre><code>imageh=plt.hexbin(x,y,extent[np.min(x),np.max(x),np.min(y),np.max(y)],alpha=0.7,gridsize=20,cmap=get_cmap("jet"),mincnt=5) </code></pre> <p>then using get_array() but I kept thinking surely there is a way just to get the number of items in each hexbin from the original statement? Plus, as an added complication the number of points and bins is slightly different if you include a np.mean filter on velocity (the first example).... so selecting the number in each hexagram directly from the query would be best.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload