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

Do not allow partial matches when updating OverlayPlot #5962

Merged
merged 3 commits into from
Nov 2, 2023
Merged

Conversation

philippjfr
Copy link
Member

For the longest time OverlayPlots tried to be smart and remappped dynamically created elements to subplots as long as they partially matched the plot spec. A plot spec consists of (<element-type>, <group>, <label>, <ndoverlay-dims>). Remapping plots like this can be more efficient but may also cause significant issues because a plot created for one element may have a bunch of state that is not correct for the new element. In theory all this state could be updated but we never did a good job at this, resulting in a variety of issues, e.g. subplots would end up assigning the wrong colors, legend order or a variety of other incorrect properties to a glyph/renderer.

Fixes:

import holoviews as hv
import pandas as pd
import panel as pn

hv.extension("bokeh")

color_dim = hv.dim("category").categorize(
    categories={"B": "red", "A": "blue", "C": "green"}, default="grey"
)
data = pd.DataFrame(
    {"x": range(5), "y": range(5), "category": ["A", "B", "A", "C", "B"]}
)


def inner(value):
    el = hv.Dataset(data).to(hv.Points, kdims=["x", "y"], groupby="category")
    if value:
        el = el.get(value)
    el.opts(color=color_dim, show_legend=False, xlim=(-1, 6), ylim=(-1, 6))
    return el.overlay()


w1 = pn.widgets.MultiSelect(value=["A"], options=list("ABC"))
pn.Row(w1, hv.DynamicMap(inner, streams=[w1.param.value])).servable()

@codecov-commenter
Copy link

codecov-commenter commented Oct 27, 2023

Codecov Report

Merging #5962 (bc7f4f0) into main (345dd00) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #5962      +/-   ##
==========================================
- Coverage   88.58%   88.58%   -0.01%     
==========================================
  Files         315      315              
  Lines       65523    65507      -16     
==========================================
- Hits        58043    58027      -16     
  Misses       7480     7480              
Flag Coverage Δ
ui-tests 23.14% <0.00%> (+<0.01%) ⬆️

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

Files Coverage Δ
holoviews/plotting/bokeh/element.py 88.36% <100.00%> (-0.02%) ⬇️
holoviews/tests/plotting/bokeh/test_overlayplot.py 100.00% <100.00%> (ø)

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

@hoxbro hoxbro added this to the 1.18.1 milestone Oct 30, 2023
@hoxbro hoxbro merged commit 3adb998 into main Nov 2, 2023
10 checks passed
@hoxbro hoxbro deleted the do_not_match branch November 2, 2023 10:04
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.

3 participants