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

[BUG] Zoom tool requires all the renderers in a subplot context #13600

Open
maximlt opened this issue Dec 13, 2023 · 0 comments
Open

[BUG] Zoom tool requires all the renderers in a subplot context #13600

maximlt opened this issue Dec 13, 2023 · 0 comments

Comments

@maximlt
Copy link
Contributor

maximlt commented Dec 13, 2023

Software versions

Python version : 3.10.13 | packaged by conda-forge | (main, Oct 26 2023, 18:09:17) [Clang 16.0.6 ]
IPython version : 8.18.1
Tornado version : 6.3.3
Bokeh version : 3.3.2
BokehJS static path : /Users/mliquet/miniconda3/envs/hv310/lib/python3.10/site-packages/bokeh/server/static
node.js version : (not installed)
npm version : (not installed)
jupyter_bokeh version : (not installed)
Operating system : macOS-13.5.2-arm64-arm-64bit

Browser name and version

No response

Jupyter notebook / Jupyter Lab version

No response

Expected behavior

@mattpap hinted at the fact that I shouldn't have to pass an explicit list of all the renders when creating a zoom tool in a subplot context, as the default value of 'auto' should lead to including all of them.

Observed behavior

Without the explicit link of renderers, it looks like the zoom tool is behaving as if level=0.

Example code

import numpy as np

from bokeh.core.properties import field
from bokeh.io import show
from bokeh.models import ColumnDataSource, Div, FactorRange, ZoomInTool, ZoomOutTool, Range1d
from bokeh.plotting import figure

n_channels = 5
n_seconds = 15

total_samples = 512*n_seconds
time = np.linspace(0, n_seconds, total_samples)
data = np.random.randn(n_channels, total_samples).cumsum(axis=1)
channels = [f"EEG {i}" for i in range(n_channels)]

x_range = Range1d(start=time.min(), end=time.max())
y_range = FactorRange(factors=channels)

p = figure(x_range=x_range, y_range=y_range, lod_threshold=None, tools="pan,reset")

source = ColumnDataSource(data=dict(time=time))
renderers = []

for i, channel in enumerate(channels):
    xy = p.subplot(
        x_source=p.x_range,
        y_source=Range1d(start=data[i].min(), end=data[i].max()),
        x_target=p.x_range,
        y_target=Range1d(start=i, end=i + 1),
    )

    source.data[channel] = data[i]
    line = xy.line(field("time"), field(channel), source=source, name=channel)
    renderers.append(line)

zoom_kwargs = dict(
    # NOTE: uncomment for this to work as expected
    # renderers=renderers,
    level=1,
    dimensions="height"
)

zoom_in = ZoomInTool(**zoom_kwargs)
zoom_out = ZoomOutTool(**zoom_kwargs)
p.add_tools(zoom_in, zoom_out)

show(p)

Stack traceback or browser console output

No response

Screenshots

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants