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

Subplots do not always render correctly in flex components #192

Closed
alexpeters1208 opened this issue Jan 2, 2024 · 4 comments · Fixed by #896
Closed

Subplots do not always render correctly in flex components #192

alexpeters1208 opened this issue Jan 2, 2024 · 4 comments · Fixed by #896
Assignees
Labels
bug Something isn't working

Comments

@alexpeters1208
Copy link
Contributor

Description

Figures with subplots (IE, figures created via Figure(rows=y, columns=x)) do not always render correctly when included in a ui.flex() call. The failure is not guaranteed, and may take a few re-runs of the same script to pop up. When it occurs, only the last plot in the subplot actually gets displayed, but the legend is correct, and all of the axes seem to try to overlap with each other.

Steps to reproduce

Here's a repro script:

from deephaven import ui
from deephaven import empty_table
from deephaven.plot.figure import Figure

@ui.component
def test():
    t = empty_table(100).update(["X = ii", "Y = Math.sin(X)"])
    plot = Figure(rows=1, cols=3). \
        new_chart(row=0, col=0). \
        plot_xy(series_name="1",
                t=t,
                x="X",
                y="Y"). \
        new_chart(row=0, col=1). \
        plot_xy(series_name="2",
                t=t,
                x="X",
                y="Y"). \
        new_chart(row=0, col=2). \
        plot_xy(series_name="3",
                t=t,
                x="X",
                y="Y"). \
        show()

    return ui.flex(
        ui.text("This is a block of text"),
        plot,
        direction="column",
        flex_grow=1
    )

Expected results

I expect this to produce the same figure with subplots every time:
Screenshot 2024-01-02 at 10 17 16 AM

Actual results

Sometimes, the following incorrect plot will be produced:
Screenshot 2024-01-02 at 10 16 50 AM

Versions

  • Engine Version: 0.31.0

  • OS: MacOS

  • Browser: Safari

  • Deephaven UI version is from ghcr.io/mofojed/deephaven-plugins:alpha

@alexpeters1208 alexpeters1208 added bug Something isn't working triage labels Jan 2, 2024
@vbabich vbabich added this to the January 2024 milestone Jan 2, 2024
@vbabich vbabich removed the triage label Jan 2, 2024
@mofojed mofojed modified the milestones: January 2024, February 2024 Feb 13, 2024
@mofojed mofojed modified the milestones: February 2024, March 2024 Mar 18, 2024
@mofojed mofojed modified the milestones: March 2024, April 2024 Apr 15, 2024
@mofojed mofojed modified the milestones: April 2024, May 2024 May 28, 2024
@mofojed mofojed modified the milestones: May 2024, June 2024 Jul 8, 2024
@vbabich vbabich modified the milestones: June 2024, July 2024 Jul 9, 2024
@jnumainville
Copy link
Collaborator

I'm unable to recreate the original issue. All traces are rendering as expected after running this several hundred times.

I did change one thing in the example by adding the width. If I don't add the width it's squished (see screenshot). @dsmmcken is something like setting the width expected or is there some way we could make this better?

from deephaven import ui
from deephaven import empty_table
from deephaven.plot.figure import Figure

@ui.component
def test():
    t = empty_table(100).update(["X = ii", "Y = Math.sin(X)"])
    plot = Figure(rows=1, cols=3). \
        new_chart(row=0, col=0). \
        plot_xy(series_name="1",
                t=t,
                x="X",
                y="Y"). \
        new_chart(row=0, col=1). \
        plot_xy(series_name="2",
                t=t,
                x="X",
                y="Y"). \
        new_chart(row=0, col=2). \
        plot_xy(series_name="3",
                t=t,
                x="X",
                y="Y"). \
        show()

    return ui.flex(
        ui.text("This is a block of text"),
        plot,
        direction="column",
        flex_grow=1,
        width="100%" # added this
    )

fig = test()

Image

@mofojed mofojed assigned dsmmcken and unassigned jnumainville Aug 12, 2024
@mofojed mofojed modified the milestones: July 2024, September 2024 Sep 3, 2024
@mofojed mofojed assigned mofojed and unassigned dsmmcken Sep 3, 2024
@mofojed
Copy link
Member

mofojed commented Sep 6, 2024

I believe this is partial a result of our change to align-items: start on ui.panel: #604
This can be fixed by using a ui.panel instead of a ui.flex:

from deephaven import ui
from deephaven import empty_table
from deephaven.plot.figure import Figure

@ui.component
def plot_test():
    t = empty_table(100).update(["X = ii", "Y = Math.sin(X)"])
    plot = Figure(rows=1, cols=3). \
        new_chart(row=0, col=0). \
        plot_xy(series_name="1",
                t=t,
                x="X",
                y="Y"). \
        new_chart(row=0, col=1). \
        plot_xy(series_name="2",
                t=t,
                x="X",
                y="Y"). \
        new_chart(row=0, col=2). \
        plot_xy(series_name="3",
                t=t,
                x="X",
                y="Y"). \
        show()

    return ui.panel(
        ui.text("This is a block of text"),
        plot,
    )

t = plot_test()

Still think we could do better...

@mofojed
Copy link
Member

mofojed commented Sep 17, 2024

@dsmmcken currently making some changes to default layouting, will need to check this with his changes.

@mofojed
Copy link
Member

mofojed commented Sep 23, 2024

Looks good with @dsmmcken 's latest changes #896
image

@mofojed mofojed linked a pull request Sep 23, 2024 that will close this issue
@mofojed mofojed assigned dsmmcken and unassigned dsmmcken Sep 23, 2024
@mofojed mofojed assigned dsmmcken and unassigned mofojed Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants