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

Sync legends of LayoutPlot #5763

Merged
merged 21 commits into from
Jul 21, 2023
Merged

Sync legends of LayoutPlot #5763

merged 21 commits into from
Jul 21, 2023

Conversation

hoxbro
Copy link
Member

@hoxbro hoxbro commented Jun 15, 2023

Closes #5674

TODO:

  • Need to add some tests
  • Work if click_policy is hide (replace muted with visibility).
  • Check whether sync_location is needed other places
  • Work with column, row
import holoviews as hv
import hvplot.pandas
import numpy as np
import pandas as pd
from holoviews.plotting.bokeh.util import select_legends

df = pd.DataFrame(np.arange(10)[:, None] * np.array([1, 2, 3]), columns=list("ABC"))
plot = (df.hvplot() + df.hvplot() + df.hvplot() + df.hvplot()).cols(2)
select_legends(plot, 0, "top_left")
screenrecord-2023-06-15_18.29.09.mp4

@codecov-commenter
Copy link

codecov-commenter commented Jun 15, 2023

Codecov Report

Merging #5763 (d7e4613) into main (003be41) will increase coverage by 0.00%.
The diff coverage is 83.51%.

@@           Coverage Diff            @@
##             main    #5763    +/-   ##
========================================
  Coverage   88.17%   88.18%            
========================================
  Files         307      307            
  Lines       62916    63056   +140     
========================================
+ Hits        55479    55603   +124     
- Misses       7437     7453    +16     
Flag Coverage Δ
ui-tests 22.38% <16.48%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
holoviews/plotting/bokeh/util.py 66.81% <65.90%> (-0.07%) ⬇️
holoviews/plotting/bokeh/element.py 88.09% <100.00%> (+0.01%) ⬆️
holoviews/plotting/bokeh/plot.py 92.42% <100.00%> (+0.07%) ⬆️
holoviews/tests/plotting/bokeh/test_plot.py 100.00% <100.00%> (ø)

... and 4 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Collaborator

@ahuang11 ahuang11 left a comment

Choose a reason for hiding this comment

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

This will be useful! Just left some comments

holoviews/plotting/bokeh/element.py Outdated Show resolved Hide resolved
holoviews/plotting/bokeh/util.py Outdated Show resolved Hide resolved
@hoxbro hoxbro added this to the 1.17.0 milestone Jun 26, 2023
Copy link
Member

@philippjfr philippjfr left a comment

Choose a reason for hiding this comment

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

Looks great!

@philippjfr
Copy link
Member

One test at least would be nice though.

@hoxbro
Copy link
Member Author

hoxbro commented Jul 19, 2023

I could "easily" add a test to select_legends, but it should mostly be seen as a small utility.

I have a hard time figuring out to make a unit test for sync_legends, as the changes are made when clicking on the canvas with changes happening in the browser.

@philippjfr
Copy link
Member

The unit test would just check that for different types of plots the CustomJS callback is set up correctly.

@hoxbro
Copy link
Member Author

hoxbro commented Jul 19, 2023

That should also be easy :)

@hoxbro hoxbro merged commit 951e5ba into main Jul 21, 2023
14 checks passed
@hoxbro hoxbro deleted the sync_legends branch July 21, 2023 15:33
@dcherian
Copy link

Amazing thank you!

Copy link

This pull request 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 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support syncing visibility between legend labels in different figures
5 participants