Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weighted Heatmap #14

Open
wrousseau opened this issue Nov 1, 2013 · 12 comments · May be fixed by #20
Open

Weighted Heatmap #14

wrousseau opened this issue Nov 1, 2013 · 12 comments · May be fixed by #20

Comments

@wrousseau
Copy link

Hi there,

Great tool, thanks a lot for it. Because I needed "weighted heatmaps" support (the possibility to add "cold" points but also the possibility to specify the dot size for each point), I have forked your project (https://github.com/wrousseau/heatmap).

Two things :

  • It's a quick hack, would you be interested in such feature for a merge ?
  • I think the only thing a bit dodgy I did is for the blending in "calcDensity". I obviously could not used your formula to compute pixel values, so I added my own but I'm not quite satisfied with the visual result. The formula I use is a result of several tries, but there is no theory behind that. If you have a better idea, I'm a taker !

Cheers

@kwauchope
Copy link

Hi,

I've done the same thing with my own install, not on git as yet. I did it slightly different than you. Two main things:

I didn't have a separate float array for the weights, just a flag that defaulted to False in the main heatmap python. This is then pushed through to the C lib so it knows to increment by 3 rather than 2 each loop. This means it was compatible with the original usage of the library.

The second and main change was the weight itself. I just normalised the weights from 0-1 using weight/maxWeight. For negative or if you wanted the lowest weight to equal zero you could try (weight-minWeight)/(maxWeight-minWeight). Dividing pixVal by the normlised weight for each point seemed to work well. I normalised the weights before calling heatmap but you could add your own normalising function in heatmap as well.

Happy to add weights to my fork if you are interested.

Cheers

@wrousseau
Copy link
Author

Hey there,

I don't really need this anymore, but I can only guess some other people will be interested eventually as I was unable to find any weighted heatmap in Python.

I think you should definatly add this feature to your fork. If it does not break compatibility, you might even want to try a pull request (not sure the original author still plans on updating this but still...).

Cheers

@BryceHarlan
Copy link

@kwauchope Weighted heat-maps would help with a project that I've been working on. I would love for you to add weights to your fork

@kwauchope
Copy link

@BryceHarlan I'll throw it in next week if that works for you.

@BryceHarlan
Copy link

@kwauchope Not a problem! Thanks for sharing!

@kwauchope
Copy link

Rough code is up, added some basic tests and getting results that look ok at least. Weights between 0 and 1 as discussed in my previous post. Not tested in anger so let me know how you go :)

@BryceHarlan
Copy link

@kwauchope Thank you so much! You may not be the best person to ask, but how exactly is the coordinate system set up? My data is ultimately mapping to a 2048 px square image, so if I wanted to log one point at pixel (1500,1500) (assuming the origin is in the bottom left and x_right and y_up are positive) would I enter (1500/2048,1500/2048, )?

@BryceHarlan
Copy link

@kwauchope Nevermind. Figured out the issue I was having after playing around with it some more. Thanks again!

@jjguy
Copy link
Owner

jjguy commented Jul 30, 2014

@BryceHarlan @kwauchope @wrousseau sorry for ignoring the thread here for so long, balancing too much in life these days.

I'm happy to merge back into the core, as long as the switches/options/etc are tight. If I need to polish them up it'll get pushed to the back burner for a while.

FWIW, I've been slow rolling changes in this area, the next block of time sink into heatmap will probably get invested in a normalization layer, so density of points is independent of the visual representation. As it exists today, if you've got a large number of points, the heatmap image is completely saturated.

@kwauchope
Copy link

Off topic from the original thread but I like the idea of normalisation, I was looking at that for one of the next things to add. Not only for high density but also to keep track of the maximum and perhaps have some sort of scale. It also means really strong points still stand out rather than all converging to 255.

@BryceHarlan
Copy link

@kwauchope @jjguy Normalization was the next layer that I was looking to add as well, so I'd love to contribute!

@jjguy
Copy link
Owner

jjguy commented Jul 31, 2014

@BryceHarlan @kwauchope see #22 for my thoughts to date on implementation. we can move this topic to that ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants