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 · 9 comments

Comments

Projects
None yet
5 participants
@denglert

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

This comment has been minimized.

ResidentMario commented Feb 21, 2017

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

@denglert

This comment has been minimized.

denglert commented Feb 21, 2017

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

@jlstevens

This comment has been minimized.

Member

jlstevens commented Feb 21, 2017

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

This comment has been minimized.

Member

philippjfr commented Feb 21, 2017

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

This comment has been minimized.

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

This comment has been minimized.

Member

philippjfr commented Feb 22, 2017

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 feature label Feb 22, 2017

@jlstevens

This comment has been minimized.

Member

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 referenced this issue Mar 26, 2018

Merged

Add HexTiles element #2482

4 of 4 tasks complete
@philippjfr

This comment has been minimized.

Member

philippjfr commented Mar 29, 2018

Now merged.

@philippjfr philippjfr closed this Mar 29, 2018

@ResidentMario

This comment has been minimized.

ResidentMario commented Mar 29, 2018

Oh cool! Time to play with holoviews again. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment