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

Add automatic categorical legend for datashaded plots #4806

Merged
merged 10 commits into from
May 26, 2022

Conversation

philippjfr
Copy link
Member

@philippjfr philippjfr commented Jan 28, 2021

Inspects the pipeline of an RGB element and discovers the shade and rasterize operations used to generate an RGB to then automatically add a legend.

Screen Shot 2021-01-28 at 1 04 12 PM

  • Clean up operation and factor out operations to traverse pipeline
  • Factor out code to render legend plot and use across all interfaces
  • Update legend when needed

@jbednar
Copy link
Member

jbednar commented Jan 28, 2021

Does this still have the property that the previous hack did, of disrupting the axis range of a plot if that plot didn't happen to include 0,0? If so that needs documenting and explaining how to work around it.

@philippjfr
Copy link
Member Author

Does this still have the property that the previous hack did, of disrupting the axis range of a plot if that plot didn't happen to include 0,0? If so that needs documenting and explaining how to work around it.

No, apply_ranges=False should avoid this.

@philippjfr
Copy link
Member Author

philippjfr commented Jan 28, 2021

Actually no, not even that, it won't cause that issue because the plot won't even take part in axis range calculation in this approach.

@jbednar
Copy link
Member

jbednar commented Jan 28, 2021

Woohoo!!!

@philippjfr philippjfr force-pushed the datashader_categorical_legend branch from 9f4e11c to 00305e5 Compare February 4, 2021 13:32
@philippjfr
Copy link
Member Author

Okay, happier with this now. I've put the operation behind a try/except as well so we don't cause any regressions in case I missed something.

@philippjfr philippjfr changed the title WIP: Add automatic categorical legend for datashaded plots Add automatic categorical legend for datashaded plots Feb 4, 2021
@jbednar
Copy link
Member

jbednar commented Feb 5, 2021

How can I get text rather than numeric labels for a plot like this?

image

Also, I'm getting warnings simply from importing HoloViews from this branch, with param 1.10.1 and pandas 1.1.5 installed:

image

@philippjfr
Copy link
Member Author

Also, I'm getting warnings simply from importing HoloViews from this branch, with param 1.10.1 and pandas 1.1.5 installed:

Already fixed in #4821

How can I get text rather than numeric labels for a plot like this?

Hmm, I suppose that's a problem. It uses what's actually in the data (which is how legends everywhere work). We could introduce a legend_labels option to allow remapping labels I suppose.

@philippjfr philippjfr force-pushed the datashader_categorical_legend branch from 1455570 to 8bcd688 Compare May 26, 2022 14:29
@codecov-commenter
Copy link

codecov-commenter commented May 26, 2022

Codecov Report

Merging #4806 (8bcd688) into master (c265cc1) will decrease coverage by 0.09%.
The diff coverage is 53.29%.

@@            Coverage Diff             @@
##           master    #4806      +/-   ##
==========================================
- Coverage   86.74%   86.64%   -0.10%     
==========================================
  Files         299      299              
  Lines       62218    62343     +125     
==========================================
+ Hits        53969    54019      +50     
- Misses       8249     8324      +75     
Impacted Files Coverage Δ
holoviews/plotting/plot.py 93.01% <ø> (ø)
holoviews/plotting/mpl/raster.py 78.52% <31.57%> (-3.51%) ⬇️
holoviews/plotting/util.py 69.49% <32.35%> (-2.06%) ⬇️
holoviews/operation/datashader.py 78.33% <43.39%> (-1.72%) ⬇️
holoviews/plotting/bokeh/raster.py 71.30% <65.21%> (-0.95%) ⬇️
holoviews/operation/element.py 69.90% <66.66%> (-0.06%) ⬇️
holoviews/plotting/mpl/element.py 89.94% <96.15%> (-0.09%) ⬇️
holoviews/plotting/bokeh/element.py 88.86% <100.00%> (ø)
holoviews/plotting/mpl/chart.py 64.02% <100.00%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c265cc1...8bcd688. Read the comment docs.

@philippjfr philippjfr merged commit 59c20c7 into master May 26, 2022
@philippjfr philippjfr deleted the datashader_categorical_legend branch May 26, 2022 15:09
@bbudescu
Copy link

Can this be used for showing legend entries of rasterized hv.Curves, too?

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.

4 participants