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

hv.Layout with sizing_mode=scale_both on its elements results in empty plot #3451

Closed
lsorber opened this issue Feb 2, 2019 · 7 comments
Closed

Comments

@lsorber
Copy link

lsorber commented Feb 2, 2019

Let's say you want to create a responsive hv.Layout with tabs. If the elements of a hv.Layout have sizing_mode=scale_both (or any sizing_mode other than fixed for that matter), the resulting plot will be empty.

I suspect this is related to @philippjfr's comment (#1230 (comment)):

The thing is that a Layout does not determine it's own size, instead all the elements making up a Layout do.

Below is a minimal example that reproduces the problem:

import numpy as np
import holoviews as hv

scatter_plots = [
    hv.Scatter(
        (np.random.randn(10), np.random.randn(10)),
        label=str(i)).opts(
            plot={
                'width': 300,
                'height': 300,
                'sizing_mode': 'scale_both'  # [1]
            })
    for i in range(5)]

hv.Layout(scatter_plots).opts(
    plot={
        'tabs': True,
        'sizing_mode': 'scale_both'
    })

# Displays an empty plot unless [1] is set to 'fixed'.
@philippjfr philippjfr added this to the v1.12.0 milestone Feb 21, 2019
@philippjfr
Copy link
Member

In 1.12 we will be completely overhauling the layouts, at that point you can set responsive=True which will default to scale both behavior.

@lsorber
Copy link
Author

lsorber commented Feb 21, 2019

Nice! Any estimate of when 1.12 would be ready for testing?

@philippjfr
Copy link
Member

It's mostly waiting on bokeh 1.1.0 to be released, if you're happy to install a bokeh dev release you can play around with it on this branch #3450 right away.

@philippjfr philippjfr modified the milestones: v1.12.0, v1.12.x Apr 22, 2019
@lsorber
Copy link
Author

lsorber commented Apr 27, 2019

Now that Holoviews 1.12.1 is out, I tried it again with your suggestion and with some slight modifications it does seem possible to get responsive graphs, nice!

However, the behaviour of responsive=True does not seem to be aligned with sizing_mode='scale_both', which is defined as [1]:

Component will responsively resize to both the available width and height, while maintaining the original or provided aspect ratio.

If you try to set both a width and a height with responsive=True, you get several warnings that look like:

WARNING:param.PointPlot08998: responsive mode could not be enabled because fixed width and height were specified.

Does that mean there is currently no way to specify the aspect ratio of a responsive graph?

import numpy as np
import holoviews as hv

hv.extension('bokeh')

scatter_plots = [
    hv.Scatter(
        (np.random.randn(10), np.random.randn(10)),
        label=str(i)).opts(
            height=300,  # Setting a `width` as well fails
            responsive=True)
    for i in range(5)]

hv.Layout(scatter_plots).opts(plot={'tabs': True})

[1] https://bokeh.pydata.org/en/latest/docs/reference/models/layouts.html#bokeh.models.layouts.LayoutDOM.sizing_mode

@jbednar
Copy link
Member

jbednar commented Apr 29, 2019

You should be able to specify the aspect or the data_aspect, depending on whether you want to specify the shape on the screen or the ratio of data values.

@lsorber
Copy link
Author

lsorber commented May 8, 2019

Great, thanks @jbednar! With that, I think this issue can be closed.

@jbednar jbednar closed this as completed May 8, 2019
@philippjfr philippjfr removed this from the v1.12.x milestone May 29, 2019
Copy link

This issue 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 24, 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

No branches or pull requests

3 participants