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

Hexbin for holoviews #1141

Closed
denglert opened this issue Feb 20, 2017 · 10 comments
Closed

Hexbin for holoviews #1141

denglert opened this issue Feb 20, 2017 · 10 comments
Labels
type: feature A major new feature
Milestone

Comments

@denglert
Copy link

denglert commented Feb 20, 2017

It would be nice to have a HoloViews equivalent of the hexbin package ( https://github.com/edzer/hexbin ), which is an extension package originally made for R. This provides binning and plotting functions for hexagonal bins and is an alternative to the point/scatter plot. Its main feature/advantage compared to the conventional scatter plot is the ability to give a better visual feedback of the density of the points.

(edit)
Existing implementations for python packages:

It seems to already have an interface to rbokeh, see:
http://ryanhafen.com/blog/plot-lots-of-data
https://rdrr.io/cran/rbokeh/man/ly_hexbin.html

@ResidentMario
Copy link

pandas and seaborn are probably better references in the Python ecosystem.

@denglert
Copy link
Author

@ResidentMario You are right, thanks. I edited my original request.

@jlstevens
Copy link
Contributor

HoloViews does have seaborn interface classes and I don't see any reason hexbin shouldn't be supported there ( @philippjfr can tell you more about our seaborn support).

Getting similar support in the bokeh backend is likely to be a much more substantial challenge as we would probably need to use another third party library or wait for bokeh to support this type of plot.

@philippjfr
Copy link
Member

Actually matplotlib ships with a hexbin plot by default, see:

http://matplotlib.org/examples/pylab_examples/hexbin_demo.html

We could fairly easily use the matplotlib version to compute the hexbins and then render those with bokeh but that would obviously mean it would that also depends on matplotlib but I suppose that's better than implementing it all ourselves or depending on other libraries like seaborn.

@jbednar
Copy link
Member

jbednar commented Feb 21, 2017

As far as I can see the only improvement that seaborn offers over the mpl version is the marginal histograms, but that would be better handled by HoloViews' own adjoint plots, right?

Note that the original request doesn't specify bokeh or mpl, just asks that we support it. If wrapping mpl's version is simple, it seems reasonable to do, particularly if its absence would make people unable to use HoloViews in their work.

@philippjfr
Copy link
Member

Here's initial prototypes for both the matplotlib and bokeh implementations:

https://anaconda.org/philippjfr/hexbins/notebook

This will need some more discussion though because since aggregation doesn't happen until plotting there is no way to normalize the color range automatically. If we had a more efficient representation for patches I'd consider storing it that way and making hexbin an operation, but I'm also considering something similar to the HeatMap element, which holds both the raw and the aggregated gridded data. The plot looks just at the aggregated data but you can apply all the usual slicing and other methods to the underlying raw data because these methods will create clones which will recompute the aggregated view. That's also problematic though because then we depend on matplotlib to do the hexagonal aggregation and the Element can't be created without it. Not sure what the best thing to do is yet.

@philippjfr philippjfr added the type: feature A major new feature label Feb 22, 2017
@jlstevens
Copy link
Contributor

jlstevens commented Feb 22, 2017

For reference the meat of the matplotlib hexbin implementation is here.

If it is possible to make it much shorter/simpler we might want to consider adding the code to utils instead of unpacking a matplotlib hexbin plot as in get_hex_data. This would help remove an unnecessary dependency on matplotlib - that said, the cost of adding the extra code might not be worth it.

@philippjfr philippjfr modified the milestone: v2.0 Mar 15, 2017
@philippjfr philippjfr modified the milestones: v2.0, v1.10 Mar 26, 2018
@philippjfr philippjfr mentioned this issue Mar 26, 2018
4 tasks
@philippjfr
Copy link
Member

Now merged.

@ResidentMario
Copy link

Oh cool! Time to play with holoviews again. 😄

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature A major new feature
Projects
None yet
Development

No branches or pull requests

5 participants