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

Improve Legend support for Layout and add documentation #5852

Merged
merged 5 commits into from
Aug 16, 2023

Conversation

hoxbro
Copy link
Member

@hoxbro hoxbro commented Aug 8, 2023

closes #5833

This PR I want to implement the following:

  • Add show_legends and legend_position to .opts for a Layout Plot. (Note that show_legends is plural)
  • Add documentation for sync_legends and show_legends in a Layout plot.
  • Add unit test for util.select_legends.
  • Maybe rename util.select_legends to util.show_legends.

Example of show_legends:
image

import holoviews as hv
import hvplot.pandas
import numpy as np
import pandas as pd

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)
plot.opts(sync_legends=True, show_legends=0, legend_position="top_left")

@hoxbro hoxbro added this to the 1.17.1 milestone Aug 8, 2023
@hoxbro hoxbro marked this pull request as draft August 8, 2023 17:01
@codecov-commenter
Copy link

codecov-commenter commented Aug 9, 2023

Codecov Report

Merging #5852 (1484cf8) into main (5ba6537) will increase coverage by 0.02%.
Report is 1 commits behind head on main.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #5852      +/-   ##
==========================================
+ Coverage   88.23%   88.26%   +0.02%     
==========================================
  Files         309      309              
  Lines       63915    63939      +24     
==========================================
+ Hits        56396    56436      +40     
+ Misses       7519     7503      -16     
Flag Coverage Δ
ui-tests 23.37% <50.00%> (+<0.01%) ⬆️

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

Files Changed Coverage Δ
holoviews/plotting/bokeh/plot.py 92.49% <100.00%> (+0.06%) ⬆️
holoviews/plotting/bokeh/util.py 68.86% <100.00%> (+1.96%) ⬆️
holoviews/tests/plotting/bokeh/test_utils.py 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

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

@hoxbro hoxbro marked this pull request as ready for review August 10, 2023 12:21
@hoxbro hoxbro requested a review from philippjfr August 16, 2023 10:23
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 good to me!

@hoxbro
Copy link
Member Author

hoxbro commented Aug 16, 2023

I have changed show_legends to None to not change current behavior like this should not show the legend of the first plot.

import holoviews as hv
import hvplot.pandas
import numpy as np
import pandas as pd

df = pd.DataFrame(np.arange(10)[:, None] * np.array([1, 2, 3]), columns=list("ABC"))
plot = (df.hvplot().opts(show_legend=False) + df.hvplot() + df.hvplot() + df.hvplot()).cols(2)
plot

@hoxbro hoxbro requested a review from philippjfr August 16, 2023 14:26
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.

Latest changes seem reasonable to me. Happy to see this merged.

@hoxbro hoxbro merged commit 68b737f into main Aug 16, 2023
14 checks passed
@hoxbro hoxbro deleted the improve_layout_legend branch August 16, 2023 14:42
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.

Document sync_legends and select_legends
3 participants