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

Show all histograms of an Overlay #5031

Merged

Conversation

peterroelants
Copy link
Contributor

I created a PR to enable showing all histograms of an Overlay:

This PR:

Illustration of new CompositeOverlay.hist() behavior. Notice the histograms being overlaid for both elements in the overlay:

I would love to get some feedback on this PR

@peterroelants
Copy link
Contributor Author

I think I still have to write/update some tests related to this. However, I couldn't find a contributor's guide on the Holoviews website that explains the Holoviews testing frameworks and principles. Can anyone provide me a reference to how to write and run tests for Holoviews?

@peterroelants
Copy link
Contributor Author

peterroelants commented Jul 18, 2021

Comparison of new vs old behavior for the regular Overlay from the snippet:

import numpy as np
import holoviews as hv

hv.extension('bokeh')


pts1 = hv.Points(np.random.randn(1000, 2) , kdims=['x', 'y'], label='p1l')
pts2 = hv.Points(np.random.randn(1000, 2) - 5, kdims=['x', 'y'], label='p2l')
pts_overlay = pts1 * pts2
plot = pts_overlay.hist(dimension=['x','y'])
print(repr(plot))
plot
  • Old behavior:
  • New behavior (this PR):

I also have a notebook that illustrates in more depth some of the features of this PR: https://gist.github.com/peterroelants/32fadcdf4d27ff6228178fa9a8a2252b#file-overlay_hists-ipynb

You have to run the notebook yourself on this branch to see the effects (GitHub Gists crashed each time when I tried to upload the notebook with embedded Holoviews/Bokeh plots)

EDIT: Update figure after updating PR

@peterroelants
Copy link
Contributor Author

Some things to be considered:

  • Is it possible to inherit colormaps from the parent plot in some way? If so, how might I enable this?
  • Currently, the legend of the overlay is replicated on each plot of the Adjoint (when adjoin=True), do we want this as a default? Or do we only want to show the legend on the main plot?

@jbednar
Copy link
Member

jbednar commented Jul 18, 2021

I'm traveling and only have my phone, but from the pictures it looks like a big improvement to me! Maybe @jlstevens or @philippjfr will be able to take a look sooner.

@jbednar
Copy link
Member

jbednar commented Jul 18, 2021

One comment: it might be good to suppress the legend for the histogram, because it's redundant for an AdjointLayout and typically overlaps the bars a lot. ETA: now your own comment shows up on my phone saying the same thing about the legends; yes, I do think they should be suppressed by default. I don't have an answer for the colormap question. Sorry for the confusing reply!

@peterroelants peterroelants force-pushed the overlay_show_all_histograms branch 3 times, most recently from 8c3d0c7 to 753d609 Compare July 20, 2021 08:28
@peterroelants
Copy link
Contributor Author

@jbednar I updated this to hide the legend in the histograms by default, and added a parameter to still enable them if needed. I also made sure that axes are aligned in the case of adjoin=True

One weird thing that I cant explain is that the histogram plot sizes of Overlays are different compared to the histograms of plain elements. E.g.:

vs

Please take your time while travelling. I'm not in a rush to get this in.

@philippjfr philippjfr added this to the v2.0 milestone Jul 26, 2021
@philippjfr
Copy link
Member

I think this is a sensible change but since it's a change in behavior would go into 2.0.

@peterroelants
Copy link
Contributor Author

I think this is a sensible change but since it's a change in behavior would go into 2.0.

@philippjfr Should I file a PR against a different branch? Or leave this as-it-is for now?

@philippjfr
Copy link
Member

You're good, master is already in "2.0" mode, e.g. a bunch of deprecations for 2.0 have already happened.

@jlstevens
Copy link
Contributor

jlstevens commented Jul 26, 2021

Thanks for the PR!

This change seems appropriate to me and as already mentioned this is a good time to allow backwards incompatible behavior.

I've not yet checked what unit tests are running here but I would want some tests that make sure index still works to select a particular layer when necessary. Otherwise I am happy with the changes made in this PR.

@jbednar
Copy link
Member

jbednar commented Jul 26, 2021

Looks great to me! @jlstevens , can you see how to avoid having the size change like that? The smaller size (equivalent to adding .opts(width=120) (or so) if I recall correctly) seems much more appropriate for an adjoint histogram, but I don't know why the size is changing when it's an overlay.

@peterroelants
Copy link
Contributor Author

peterroelants commented Aug 6, 2021

@jlstevens I rebased this PR on latest master, and most tests seem to be passing. The ones that fail seem to fail due to unrelated reasons:

All of them are Python 3.6 tests

@peterroelants
Copy link
Contributor Author

I would love to get this merged in at some point.

Is there anything that I can do on my side to get this approved and merged?

@jlstevens
Copy link
Contributor

Sorry for letting this languish!

I agree that those test failures are unrelated. I will now approve this PR (looks fine to me) but I will wait a bit to give @philippjfr to also have a look. I'll merge at the end of the day regardless.

Copy link
Contributor

@jlstevens jlstevens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

I don't think we need to worry about backwards compatibility as it will end up on the 2.0 branch. The only thing that would be nice to add would be some additional unit tests...

@jlstevens
Copy link
Contributor

Actually, there is the size issue that @jbednar mentions. I'll have a look now...

@jlstevens
Copy link
Contributor

The sizing issue is unrelated to this PR: the problem is about how overlays become adjoint which is a separate problem.

@peterroelants Can you have a look at the issues and report this if it hasn't been already? At which point I am happy to merge.

@peterroelants
Copy link
Contributor Author

@jlstevens I couldn't find an existing issue related to the adjoint overlays resulting in an unexpected plot size. I created a issue for it at #5072

@jlstevens
Copy link
Contributor

Thanks!

I'm going to go ahead and merge. That way we can test and iron out any other issues before the 2.0 release.

@jlstevens jlstevens merged commit b1421c4 into holoviz:master Sep 1, 2021
@peterroelants peterroelants deleted the overlay_show_all_histograms branch September 2, 2021 05:27
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 this pull request may close these issues.

4 participants